]> granicus.if.org Git - python/commitdiff
Fix memory leak in exec statement with code object -- the None returned
authorGuido van Rossum <guido@python.org>
Tue, 11 Nov 1997 16:29:38 +0000 (16:29 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Nov 1997 16:29:38 +0000 (16:29 +0000)
by PyEval_EvalCode() on success was never DECREF'ed.

Fix by Bernhard Herzog.

Python/ceval.c

index dd7faf945ce6993eeb5e72ad82df5abea064894f..fb179d1aa6e1a18724ce7f4d98a10ae038439d1c 100644 (file)
@@ -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)) {