]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix possible refleak in MAKE_FUNCTION (closes #26991)
authorBenjamin Peterson <benjamin@python.org>
Tue, 17 May 2016 05:52:40 +0000 (22:52 -0700)
committerBenjamin Peterson <benjamin@python.org>
Tue, 17 May 2016 05:52:40 +0000 (22:52 -0700)
Patch by Xiang Zhang.

Misc/NEWS
Python/ceval.c

index 36981d2a89ac66ac36323400b6f1e2430676c1cb..97ddbb12f3dd2ae863da5a9ed4ea54067e80a6d9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ Release date: tba
 Core and Builtins
 -----------------
 
+- Issue #26991: Fix possible refleak when creating a function with annotations.
+
 - Issue #27039: Fixed bytearray.remove() for values greater than 127.  Patch by
   Joe Jevnik.
 
index ee79c219555a065637eb917ca860735447dc940a..3758b0936ab730048aa0be2304e15d0b9d1bf391 100644 (file)
@@ -3284,6 +3284,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                 PyObject *anns = PyDict_New();
                 if (anns == NULL) {
                     Py_DECREF(func);
+                    Py_DECREF(names);
                     goto error;
                 }
                 name_ix = PyTuple_Size(names);
@@ -3299,9 +3300,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                     if (err != 0) {
                         Py_DECREF(anns);
                         Py_DECREF(func);
+                        Py_DECREF(names);
                         goto error;
                     }
                 }
+                Py_DECREF(names);
 
                 if (PyFunction_SetAnnotations(func, anns) != 0) {
                     /* Can't happen unless
@@ -3311,7 +3314,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                     goto error;
                 }
                 Py_DECREF(anns);
-                Py_DECREF(names);
             }
 
             /* XXX Maybe this should be a separate opcode? */