]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30547: Fix multiple reference leaks (#1995)
authorStéphane Wirtel <stephane@wirtel.be>
Thu, 8 Jun 2017 11:13:20 +0000 (13:13 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 8 Jun 2017 11:13:20 +0000 (13:13 +0200)
Fix regressions introduced by:

- bpo-22257: commits 1abcf6700b4da6207fe859de40c6c1bada6b4fec and 6b4be195cd8868b76eb6fbe166acc39beee8ce36

Co-Authored-By: Victor Stinner <victor.stinner@gmail.com>
Co-Authored-By: Louie Lu <git@louie.lu>
Python/pylifecycle.c

index 048c2b283d48b463558de875d1809c4d53c31922..ec26824f839eeed5509a6a73445de55f9283f8a0 100644 (file)
@@ -302,9 +302,11 @@ initimport(PyInterpreterState *interp, PyObject *sysmod)
 
     /* Install importlib as the implementation of import */
     value = PyObject_CallMethod(importlib, "_install", "OO", sysmod, impmod);
-    if (value != NULL)
+    if (value != NULL) {
+        Py_DECREF(value);
         value = PyObject_CallMethod(importlib,
                                     "_install_external_importers", "");
+    }
     if (value == NULL) {
         PyErr_Print();
         Py_FatalError("Py_Initialize: importlib install failed");
@@ -325,6 +327,7 @@ initexternalimport(PyInterpreterState *interp)
         PyErr_Print();
         Py_FatalError("Py_EndInitialization: external importer setup failed");
     }
+    Py_DECREF(value);
 }