changeset: 101396:eaa3a71a6f62 branch: 3.5 parent: 101394:ce1b14ed5445 user: Benjamin Peterson date: Mon May 16 22:52:40 2016 -0700 files: Misc/NEWS Python/ceval.c description: fix possible refleak in MAKE_FUNCTION (closes #26991) Patch by Xiang Zhang. diff -r ce1b14ed5445 -r eaa3a71a6f62 Misc/NEWS --- a/Misc/NEWS Mon May 16 23:32:28 2016 -0400 +++ b/Misc/NEWS Mon May 16 22:52:40 2016 -0700 @@ -10,6 +10,8 @@ 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 -r ce1b14ed5445 -r eaa3a71a6f62 Python/ceval.c --- a/Python/ceval.c Mon May 16 23:32:28 2016 -0400 +++ b/Python/ceval.c Mon May 16 22:52:40 2016 -0700 @@ -3284,6 +3284,7 @@ PyObject *anns = PyDict_New(); if (anns == NULL) { Py_DECREF(func); + Py_DECREF(names); goto error; } name_ix = PyTuple_Size(names); @@ -3299,9 +3300,11 @@ 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 @@ goto error; } Py_DECREF(anns); - Py_DECREF(names); } /* XXX Maybe this should be a separate opcode? */