Commit bea47e76 authored by Marc-André Lemburg's avatar Marc-André Lemburg

Vladimir MARANGOZOV <Vladimir.Marangozov@inrialpes.fr>:

This patch fixes an optimisation mystery in _PyUnicodeNew causing segfaults
on AIX when the interpreter is compiled with -O.
parent b248b7f8
...@@ -213,9 +213,8 @@ PyUnicodeObject *_PyUnicode_New(int length) ...@@ -213,9 +213,8 @@ PyUnicodeObject *_PyUnicode_New(int length)
/* Unicode freelist & memory allocation */ /* Unicode freelist & memory allocation */
if (unicode_freelist) { if (unicode_freelist) {
unicode = unicode_freelist; unicode = unicode_freelist;
unicode_freelist = *(PyUnicodeObject **)unicode_freelist; unicode_freelist = *(PyUnicodeObject **)unicode;
unicode_freelist_size--; unicode_freelist_size--;
PyObject_INIT(unicode, &PyUnicode_Type);
if (unicode->str) { if (unicode->str) {
/* Keep-Alive optimization: we only upsize the buffer, /* Keep-Alive optimization: we only upsize the buffer,
never downsize it. */ never downsize it. */
...@@ -225,9 +224,11 @@ PyUnicodeObject *_PyUnicode_New(int length) ...@@ -225,9 +224,11 @@ PyUnicodeObject *_PyUnicode_New(int length)
goto onError; goto onError;
} }
} }
else else {
unicode->str = PyMem_NEW(Py_UNICODE, length + 1); unicode->str = PyMem_NEW(Py_UNICODE, length + 1);
} }
PyObject_INIT(unicode, &PyUnicode_Type);
}
else { else {
unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type); unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type);
if (unicode == NULL) if (unicode == NULL)
......
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