]> granicus.if.org Git - python/commitdiff
bpo-29655: Fixed possible reference leaks in `import *`. (#301) (#348)
authorBerker Peksag <berker.peksag@gmail.com>
Mon, 27 Feb 2017 17:41:21 +0000 (20:41 +0300)
committerGitHub <noreply@github.com>
Mon, 27 Feb 2017 17:41:21 +0000 (20:41 +0300)
Patch by Matthias Bussonnier.

(cherry picked from commit 160edb43571311a3785785c1dfa784afc52d87be)

Python/ceval.c

index c9e9c327f31401f4f43ec67721507010d9f8d60b..83667353af232c10130fba1045367de62fc02fbf 100644 (file)
@@ -2857,13 +2857,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
         TARGET(IMPORT_STAR) {
             PyObject *from = POP(), *locals;
             int err;
-            if (PyFrame_FastToLocalsWithError(f) < 0)
+            if (PyFrame_FastToLocalsWithError(f) < 0) {
+                Py_DECREF(from);
                 goto error;
+            }
 
             locals = f->f_locals;
             if (locals == NULL) {
                 PyErr_SetString(PyExc_SystemError,
                     "no locals found during 'import *'");
+                Py_DECREF(from);
                 goto error;
             }
             err = import_all_from(locals, from);