mirror of
https://github.com/python/cpython.git
synced 2025-07-28 05:34:31 +00:00
#3378: in case of no memory, don't leak even more memory. :)
This commit is contained in:
parent
3369167089
commit
1ad108db05
1 changed files with 7 additions and 6 deletions
|
@ -1553,10 +1553,10 @@ err_input(perrdetail *err)
|
|||
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 @@ err_input(perrdetail *err)
|
|||
}
|
||||
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 @@ err_input(perrdetail *err)
|
|||
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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue