Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bea47e7

Browse files
committed
Vladimir MARANGOZOV <[email protected]>:
This patch fixes an optimisation mystery in _PyUnicodeNew causing segfaults on AIX when the interpreter is compiled with -O.
1 parent b248b7f commit bea47e7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Objects/unicodeobject.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ PyUnicodeObject *_PyUnicode_New(int length)
213213
/* Unicode freelist & memory allocation */
214214
if (unicode_freelist) {
215215
unicode = unicode_freelist;
216-
unicode_freelist = *(PyUnicodeObject **)unicode_freelist;
216+
unicode_freelist = *(PyUnicodeObject **)unicode;
217217
unicode_freelist_size--;
218-
PyObject_INIT(unicode, &PyUnicode_Type);
219218
if (unicode->str) {
220219
/* Keep-Alive optimization: we only upsize the buffer,
221220
never downsize it. */
@@ -225,8 +224,10 @@ PyUnicodeObject *_PyUnicode_New(int length)
225224
goto onError;
226225
}
227226
}
228-
else
227+
else {
229228
unicode->str = PyMem_NEW(Py_UNICODE, length + 1);
229+
}
230+
PyObject_INIT(unicode, &PyUnicode_Type);
230231
}
231232
else {
232233
unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type);

0 commit comments

Comments
 (0)