summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-07-31 23:39:05 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-07-31 23:39:05 (GMT)
commit06847b13ca28ef88e0ded4ce985c46317ba8cdaf (patch)
tree538beea91ca49f9cfeb724c4de85824cb45a2f4d /Objects
parentad9604003ccfcf956375bbc2aeaac078b7bc9b23 (diff)
downloadcpython-06847b13ca28ef88e0ded4ce985c46317ba8cdaf.zip
cpython-06847b13ca28ef88e0ded4ce985c46317ba8cdaf.tar.gz
cpython-06847b13ca28ef88e0ded4ce985c46317ba8cdaf.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7abf984..603c507 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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;