[Python-checkins] r65131 - python/trunk/Python/pythonrun.c

georg.brandl python-checkins at python.org
Sat Jul 19 12:08:55 CEST 2008


Author: georg.brandl
Date: Sat Jul 19 12:08:55 2008
New Revision: 65131

Log:
#3378: in case of no memory, don't leak even more memory. :)


Modified:
   python/trunk/Python/pythonrun.c

Modified: python/trunk/Python/pythonrun.c
==============================================================================
--- python/trunk/Python/pythonrun.c	(original)
+++ python/trunk/Python/pythonrun.c	Sat Jul 19 12:08:55 2008
@@ -1553,10 +1553,10 @@
 	case E_INTR:
 		if (!PyErr_Occurred())
 			PyErr_SetNone(PyExc_KeyboardInterrupt);
-		return;
+		goto cleanup;
 	case E_NOMEM:
 		PyErr_NoMemory();
-		return;
+		goto cleanup;
 	case E_EOF:
 		msg = "unexpected EOF while parsing";
 		break;
@@ -1601,10 +1601,6 @@
 	}
 	v = Py_BuildValue("(ziiz)", err->filename,
 			  err->lineno, err->offset, err->text);
-	if (err->text != NULL) {
-		PyObject_FREE(err->text);
-		err->text = NULL;
-	}
 	w = NULL;
 	if (v != NULL)
 		w = Py_BuildValue("(sO)", msg, v);
@@ -1612,6 +1608,11 @@
 	Py_XDECREF(v);
 	PyErr_SetObject(errtype, w);
 	Py_XDECREF(w);
+cleanup:
+	if (err->text != NULL) {
+		PyObject_FREE(err->text);
+		err->text = NULL;
+	}
 }
 
 /* Print fatal error message and abort */


More information about the Python-checkins mailing list