Kaydet (Commit) 1ad108db authored tarafından Georg Brandl's avatar Georg Brandl

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

üst 33691670
...@@ -1553,10 +1553,10 @@ err_input(perrdetail *err) ...@@ -1553,10 +1553,10 @@ err_input(perrdetail *err)
case E_INTR: case E_INTR:
if (!PyErr_Occurred()) if (!PyErr_Occurred())
PyErr_SetNone(PyExc_KeyboardInterrupt); PyErr_SetNone(PyExc_KeyboardInterrupt);
return; goto cleanup;
case E_NOMEM: case E_NOMEM:
PyErr_NoMemory(); PyErr_NoMemory();
return; goto cleanup;
case E_EOF: case E_EOF:
msg = "unexpected EOF while parsing"; msg = "unexpected EOF while parsing";
break; break;
...@@ -1601,10 +1601,6 @@ err_input(perrdetail *err) ...@@ -1601,10 +1601,6 @@ err_input(perrdetail *err)
} }
v = Py_BuildValue("(ziiz)", err->filename, v = Py_BuildValue("(ziiz)", err->filename,
err->lineno, err->offset, err->text); err->lineno, err->offset, err->text);
if (err->text != NULL) {
PyObject_FREE(err->text);
err->text = NULL;
}
w = NULL; w = NULL;
if (v != NULL) if (v != NULL)
w = Py_BuildValue("(sO)", msg, v); w = Py_BuildValue("(sO)", msg, v);
...@@ -1612,6 +1608,11 @@ err_input(perrdetail *err) ...@@ -1612,6 +1608,11 @@ err_input(perrdetail *err)
Py_XDECREF(v); Py_XDECREF(v);
PyErr_SetObject(errtype, w); PyErr_SetObject(errtype, w);
Py_XDECREF(w); Py_XDECREF(w);
cleanup:
if (err->text != NULL) {
PyObject_FREE(err->text);
err->text = NULL;
}
} }
/* Print fatal error message and abort */ /* Print fatal error message and abort */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment