From: Marc-André Lemburg Date: Sat, 17 Jun 2000 20:31:17 +0000 (+0000) Subject: Vladimir MARANGOZOV : X-Git-Tag: v2.0b1~1492 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bea47e768de9918856473f9f27da8929f5449b8d;p=python Vladimir MARANGOZOV : This patch fixes an optimisation mystery in _PyUnicodeNew causing segfaults on AIX when the interpreter is compiled with -O. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index bfc59dd97a..e6d2a1a5f9 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -213,9 +213,8 @@ PyUnicodeObject *_PyUnicode_New(int length) /* Unicode freelist & memory allocation */ if (unicode_freelist) { unicode = unicode_freelist; - unicode_freelist = *(PyUnicodeObject **)unicode_freelist; + unicode_freelist = *(PyUnicodeObject **)unicode; unicode_freelist_size--; - PyObject_INIT(unicode, &PyUnicode_Type); if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, never downsize it. */ @@ -225,8 +224,10 @@ PyUnicodeObject *_PyUnicode_New(int length) goto onError; } } - else + else { unicode->str = PyMem_NEW(Py_UNICODE, length + 1); + } + PyObject_INIT(unicode, &PyUnicode_Type); } else { unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type);