From: Victor Stinner Date: Thu, 7 Feb 2013 22:17:34 +0000 (+0100) Subject: (Merge 3.3) Issue #17137: When an Unicode string is resized, the internal wide X-Git-Tag: v3.4.0a1~1425 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cfd2c1b4ccb4355a914c7e4084141d522ada8666;p=thirdparty%2FPython%2Fcpython.git (Merge 3.3) Issue #17137: When an Unicode string is resized, the internal wide character string (wstr) format is now cleared. --- cfd2c1b4ccb4355a914c7e4084141d522ada8666 diff --cc Objects/unicodeobject.c index 8596e544233e,51160f852d29..4d380490607e --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@@ -717,9 -702,10 +717,13 @@@ resize_compact(PyObject *unicode, Py_ss if (!PyUnicode_IS_ASCII(unicode)) _PyUnicode_WSTR_LENGTH(unicode) = length; } + else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) { + PyObject_DEL(_PyUnicode_WSTR(unicode)); + _PyUnicode_WSTR(unicode) = NULL; + } +#ifdef Py_DEBUG + unicode_fill_invalid(unicode, old_length); +#endif PyUnicode_WRITE(PyUnicode_KIND(unicode), PyUnicode_DATA(unicode), length, 0); assert(_PyUnicode_CheckConsistency(unicode, 0));