]> granicus.if.org Git - python/commitdiff
Fix a memory leak in reloading extension modules #3667
authorBenjamin Peterson <benjamin@python.org>
Thu, 4 Sep 2008 02:28:15 +0000 (02:28 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 4 Sep 2008 02:28:15 +0000 (02:28 +0000)
Reviewer: Barry Warsaw

Python/import.c

index 8159b5e6d2ad343065ee57ecf8a6f29a5dc5663f..d87d7515a0d887e406f25476693478b39a758107 100644 (file)
@@ -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);