]> granicus.if.org Git - python/commitdiff
bpo-29655: Fixed possible reference leaks in `import *`. (#301)
authorMatthias Bussonnier <bussonniermatthias@gmail.com>
Sun, 26 Feb 2017 05:58:05 +0000 (21:58 -0800)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 26 Feb 2017 05:58:05 +0000 (07:58 +0200)
Patch by Matthias Bussonnier.

Python/ceval.c

index 0a82965c51732081a6521ed65b00bb46eeda6056..4022ba2ac96d34dbeca325cd3f5324f798660ce6 100644 (file)
@@ -2810,13 +2810,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);