From: Guido van Rossum Date: Tue, 11 Nov 1997 16:29:38 +0000 (+0000) Subject: Fix memory leak in exec statement with code object -- the None returned X-Git-Tag: v1.5b1~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfed725e2c351676174ed2e046fe6c5288e21488;p=python 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. --- diff --git a/Python/ceval.c b/Python/ceval.c index dd7faf945c..fb179d1aa6 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)) {