[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.119, 1.1.2.120

nnorwitz@users.sourceforge.net nnorwitz at users.sourceforge.net
Fri Oct 14 09:22:24 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21603/Python

Modified Files:
      Tag: ast-branch
	newcompile.c 
Log Message:
Fix some memory leaks in error conditions (needs work)

Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.119
retrieving revision 1.1.2.120
diff -u -d -r1.1.2.119 -r1.1.2.120
--- newcompile.c	13 Oct 2005 04:45:58 -0000	1.1.2.119
+++ newcompile.c	14 Oct 2005 07:22:20 -0000	1.1.2.120
@@ -1205,6 +1205,7 @@
 	u->u_argcount = 0;
 	u->u_ste = PySymtable_Lookup(c->c_st, key);
 	if (!u->u_ste) {
+		PyObject_Free(u);
 		return 0;
 	}
 	Py_INCREF(name);
@@ -1221,11 +1222,17 @@
 	u->u_lineno = 0;
 	u->u_lineno_set = false;
 	u->u_consts = PyDict_New();
-	if (!u->u_consts)
+	if (!u->u_consts) {
+		/* XXX: free_u->u_ste); */
+		PyObject_Free(u);
 		return 0;
+	}
 	u->u_names = PyDict_New();
-	if (!u->u_names)
+	if (!u->u_names) {
+		/* XXX: free_u->u_ste); */
+		PyObject_Free(u);
 		return 0;
+	}
 
         u->u_private = NULL;
 
@@ -1235,8 +1242,11 @@
 	/* Push the old compiler_unit on the stack. */
 	if (c->u) {
 		PyObject *wrapper = PyCObject_FromVoidPtr(c->u, NULL);
-		if (PyList_Append(c->c_stack, wrapper) < 0)
+		if (PyList_Append(c->c_stack, wrapper) < 0) {
+			/* XXX: free_u->u_ste); */
+			PyObject_Free(u);
 			return 0;
+		}
 		Py_DECREF(wrapper);
 		fprintf(stderr, "stack = %s\n", PyObject_REPR(c->c_stack));
                 u->u_private = c->u->u_private;



More information about the Python-checkins mailing list