Kaydet (Commit) ad956533 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

Fix a memory leak in reloading extension modules #3667

Reviewer: Barry Warsaw
üst a7f4f5a7
...@@ -612,7 +612,6 @@ _PyImport_FindExtension(char *name, char *filename) ...@@ -612,7 +612,6 @@ _PyImport_FindExtension(char *name, char *filename)
mod = PyImport_AddModule(name); mod = PyImport_AddModule(name);
if (mod == NULL) if (mod == NULL)
return NULL; return NULL;
Py_INCREF(mod);
mdict = PyModule_GetDict(mod); mdict = PyModule_GetDict(mod);
if (mdict == NULL) if (mdict == NULL)
return NULL; return NULL;
...@@ -626,6 +625,7 @@ _PyImport_FindExtension(char *name, char *filename) ...@@ -626,6 +625,7 @@ _PyImport_FindExtension(char *name, char *filename)
if (mod == NULL) if (mod == NULL)
return NULL; return NULL;
PyDict_SetItemString(PyImport_GetModuleDict(), name, mod); PyDict_SetItemString(PyImport_GetModuleDict(), name, mod);
Py_DECREF(mod);
} }
if (_PyState_AddModule(mod, def) < 0) { if (_PyState_AddModule(mod, def) < 0) {
PyDict_DelItemString(PyImport_GetModuleDict(), name); PyDict_DelItemString(PyImport_GetModuleDict(), name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment