From: Benjamin Peterson Date: Thu, 4 Sep 2008 02:28:15 +0000 (+0000) Subject: Fix a memory leak in reloading extension modules #3667 X-Git-Tag: v3.0rc1~107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad9565338c10be8c1ff14b234cb0bb0dde2b80f6;p=python Fix a memory leak in reloading extension modules #3667 Reviewer: Barry Warsaw --- diff --git a/Python/import.c b/Python/import.c index 8159b5e6d2..d87d7515a0 100644 --- a/Python/import.c +++ b/Python/import.c @@ -612,7 +612,6 @@ _PyImport_FindExtension(char *name, char *filename) mod = PyImport_AddModule(name); if (mod == NULL) return NULL; - Py_INCREF(mod); mdict = PyModule_GetDict(mod); if (mdict == NULL) return NULL; @@ -626,6 +625,7 @@ _PyImport_FindExtension(char *name, char *filename) if (mod == NULL) return NULL; PyDict_SetItemString(PyImport_GetModuleDict(), name, mod); + Py_DECREF(mod); } if (_PyState_AddModule(mod, def) < 0) { PyDict_DelItemString(PyImport_GetModuleDict(), name);