fix possible refleak in MAKE_FUNCTION (closes #26991)

Patch by Xiang Zhang.
This commit is contained in:
Benjamin Peterson 2016-05-16 22:52:40 -07:00
parent 0495fa81e6
commit ad887cf7d1
2 changed files with 5 additions and 1 deletions

View 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? */