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

Skip to content

Commit dfed725

Browse files
committed
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.
1 parent 3120bc3 commit dfed725

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Python/ceval.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,9 +2773,11 @@ exec_statement(f, prog, globals, locals)
27732773
if (PyDict_GetItemString(globals, "__builtins__") == NULL)
27742774
PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
27752775
if (PyCode_Check(prog)) {
2776-
if (PyEval_EvalCode((PyCodeObject *) prog,
2777-
globals, locals) == NULL)
2776+
v = PyEval_EvalCode((PyCodeObject *) prog,
2777+
globals, locals);
2778+
if (v == NULL)
27782779
return -1;
2780+
Py_DECREF(v);
27792781
return 0;
27802782
}
27812783
if (PyFile_Check(prog)) {

0 commit comments

Comments
 (0)