Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad95653

Browse files
committed
Fix a memory leak in reloading extension modules #3667
Reviewer: Barry Warsaw
1 parent a7f4f5a commit ad95653

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Python/import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,6 @@ _PyImport_FindExtension(char *name, char *filename)
612612
mod = PyImport_AddModule(name);
613613
if (mod == NULL)
614614
return NULL;
615-
Py_INCREF(mod);
616615
mdict = PyModule_GetDict(mod);
617616
if (mdict == NULL)
618617
return NULL;
@@ -626,6 +625,7 @@ _PyImport_FindExtension(char *name, char *filename)
626625
if (mod == NULL)
627626
return NULL;
628627
PyDict_SetItemString(PyImport_GetModuleDict(), name, mod);
628+
Py_DECREF(mod);
629629
}
630630
if (_PyState_AddModule(mod, def) < 0) {
631631
PyDict_DelItemString(PyImport_GetModuleDict(), name);

0 commit comments

Comments
 (0)