diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-02-07 23:12:46 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-02-07 23:12:46 +0100 |
commit | bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48 (patch) | |
tree | d78b2fead0311d37b6f76d0a3466fd78196c8c31 /Objects/unicodeobject.c | |
parent | 2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb (diff) | |
download | cpython-git-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.tar.gz |
Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index abe793dfd4..51160f852d 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -702,6 +702,10 @@ resize_compact(PyObject *unicode, Py_ssize_t length) 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; + } PyUnicode_WRITE(PyUnicode_KIND(unicode), PyUnicode_DATA(unicode), length, 0); assert(_PyUnicode_CheckConsistency(unicode, 0)); |