bpo-46347: Fix memory leak in PyEval_EvalCodeEx. (GH-30546)

First introduced in 0332e569c1
(cherry picked from commit 607d8a838f)

Co-authored-by: Yury Selivanov <yury@edgedb.com>
This commit is contained in:
Miss Islington (bot) 2022-01-11 15:09:22 -08:00 committed by GitHub
parent 6f035c07e0
commit b1a94f1fab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 7 deletions

View file

@ -5132,16 +5132,9 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
}
allargs = newargs;
}
PyObject **kwargs = PyMem_Malloc(sizeof(PyObject *)*kwcount);
if (kwargs == NULL) {
res = NULL;
Py_DECREF(kwnames);
goto fail;
}
for (int i = 0; i < kwcount; i++) {
Py_INCREF(kws[2*i]);
PyTuple_SET_ITEM(kwnames, i, kws[2*i]);
kwargs[i] = kws[2*i+1];
}
PyFrameConstructor constr = {
.fc_globals = globals,