Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad887cf

Browse files
committed
fix possible refleak in MAKE_FUNCTION (closes #26991)
Patch by Xiang Zhang.
1 parent 0495fa8 commit ad887cf

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Release date: tba
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #26991: Fix possible refleak when creating a function with annotations.
14+
1315
- Issue #27039: Fixed bytearray.remove() for values greater than 127. Patch by
1416
Joe Jevnik.
1517

Python/ceval.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3284,6 +3284,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
32843284
PyObject *anns = PyDict_New();
32853285
if (anns == NULL) {
32863286
Py_DECREF(func);
3287+
Py_DECREF(names);
32873288
goto error;
32883289
}
32893290
name_ix = PyTuple_Size(names);
@@ -3299,9 +3300,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
32993300
if (err != 0) {
33003301
Py_DECREF(anns);
33013302
Py_DECREF(func);
3303+
Py_DECREF(names);
33023304
goto error;
33033305
}
33043306
}
3307+
Py_DECREF(names);
33053308

33063309
if (PyFunction_SetAnnotations(func, anns) != 0) {
33073310
/* Can't happen unless
@@ -3311,7 +3314,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
33113314
goto error;
33123315
}
33133316
Py_DECREF(anns);
3314-
Py_DECREF(names);
33153317
}
33163318

33173319
/* XXX Maybe this should be a separate opcode? */

0 commit comments

Comments
 (0)