diff Python/ceval.c @ 6573:67a2afcdd21c legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Tue, 11 Nov 1997 16:29:38 +0000
parents 21b93d98926b
children 6d6fec2eeef6
line wrap: on
line diff
--- a/Python/ceval.c	Sat Nov 08 07:16:19 1997 +0000
+++ b/Python/ceval.c	Tue Nov 11 16:29:38 1997 +0000
@@ -2773,9 +2773,11 @@
 	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)) {