summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-11-11 16:29:38 (GMT)
committerGuido van Rossum <guido@python.org>1997-11-11 16:29:38 (GMT)
commitdfed725e2c351676174ed2e046fe6c5288e21488 (patch)
tree2a527d0c6f6c7ecc8a542432ad771cf5040f4bca /Python/ceval.c
parent3120bc388805ba51d48bdfb2ed9f2923ee2241b2 (diff)
downloadcpython-dfed725e2c351676174ed2e046fe6c5288e21488.zip
cpython-dfed725e2c351676174ed2e046fe6c5288e21488.tar.gz
cpython-dfed725e2c351676174ed2e046fe6c5288e21488.tar.bz2
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.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index dd7faf9..fb179d1 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2773,9 +2773,11 @@ exec_statement(f, prog, globals, locals)
if (PyDict_GetItemString(globals, "__builtins__") == NULL)
PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
if (PyCode_Check(prog)) {
- if (PyEval_EvalCode((PyCodeObject *) prog,
- globals, locals) == NULL)
+ v = PyEval_EvalCode((PyCodeObject *) prog,
+ globals, locals);
+ if (v == NULL)
return -1;
+ Py_DECREF(v);
return 0;
}
if (PyFile_Check(prog)) {