From ab1cb80b435a34e4f908c97cd2f3a7fe8add6505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Wirtel?= Date: Thu, 8 Jun 2017 13:13:20 +0200 Subject: [PATCH] bpo-30547: Fix multiple reference leaks (#1995) Fix regressions introduced by: - bpo-22257: commits 1abcf6700b4da6207fe859de40c6c1bada6b4fec and 6b4be195cd8868b76eb6fbe166acc39beee8ce36 Co-Authored-By: Victor Stinner Co-Authored-By: Louie Lu --- Python/pylifecycle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 048c2b283d4..ec26824f839 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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); }