mirror of
https://github.com/python/cpython.git
synced 2025-07-31 15:14:22 +00:00
Correct a crash when two successive unicode allocations fail with a MemoryError:
the freelist contained half-initialized objects with freed pointers. The comment /* XXX UNREF/NEWREF interface should be more symmetrical */ was copied from tupleobject.c, and appears in some other places. I sign the petition.
This commit is contained in:
parent
ad9604003c
commit
06847b13ca
2 changed files with 17 additions and 1 deletions
|
@ -315,7 +315,7 @@ PyUnicodeObject *_PyUnicode_New(Py_ssize_t length)
|
|||
if ((unicode->length < length) &&
|
||||
unicode_resize(unicode, length) < 0) {
|
||||
PyObject_DEL(unicode->str);
|
||||
goto onError;
|
||||
unicode->str = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -352,6 +352,8 @@ PyUnicodeObject *_PyUnicode_New(Py_ssize_t length)
|
|||
return unicode;
|
||||
|
||||
onError:
|
||||
/* XXX UNREF/NEWREF interface should be more symmetrical */
|
||||
_Py_DEC_REFTOTAL;
|
||||
_Py_ForgetReference((PyObject *)unicode);
|
||||
PyObject_Del(unicode);
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue