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

(cherry picked from commit 160edb43571311a3785785c1dfa784afc52d87be)

Python/ceval.c

index d3239089284c481065df9209e95695f780f43cc7..62badebca6502d38ce6bf067d97bee5092d8342a 100644 (file)
@@ -2832,13 +2832,16 @@ PyEval_EvalFrameEx(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;
             }
             READ_TIMESTAMP(intr0);