From ad887cf7d1257e73819fa9fd926f15849192888c Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 16 May 2016 22:52:40 -0700 Subject: fix possible refleak in MAKE_FUNCTION (closes #26991) Patch by Xiang Zhang. --- Misc/NEWS | 2 ++ Python/ceval.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 36981d2..97ddbb1 100644 --- 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. diff --git a/Python/ceval.c b/Python/ceval.c index ee79c21..3758b09 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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? */ -- cgit v0.12