mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fix memory leak in exec statement with code object -- the None returned
by PyEval_EvalCode() on success was never DECREF'ed. Fix by Bernhard Herzog.
This commit is contained in:
parent
3120bc3888
commit
dfed725e2c
1 changed files with 4 additions and 2 deletions
|
@ -2773,9 +2773,11 @@ exec_statement(f, prog, globals, locals)
|
||||||
if (PyDict_GetItemString(globals, "__builtins__") == NULL)
|
if (PyDict_GetItemString(globals, "__builtins__") == NULL)
|
||||||
PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
|
PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
|
||||||
if (PyCode_Check(prog)) {
|
if (PyCode_Check(prog)) {
|
||||||
if (PyEval_EvalCode((PyCodeObject *) prog,
|
v = PyEval_EvalCode((PyCodeObject *) prog,
|
||||||
globals, locals) == NULL)
|
globals, locals);
|
||||||
|
if (v == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
Py_DECREF(v);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (PyFile_Check(prog)) {
|
if (PyFile_Check(prog)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue