Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 48024:7ad6e4cd7713 legacy-trunk
#3378: in case of no memory, don't leak even more memory. :)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sat, 19 Jul 2008 10:08:55 +0000 |
| parents | 6f132a26b22f |
| children | b1682c693b9a |
line wrap: on
line diff
--- a/Python/pythonrun.c Sat Jul 19 00:43:00 2008 +0000 +++ b/Python/pythonrun.c Sat Jul 19 10:08:55 2008 +0000 @@ -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 */
