summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-02-07 22:12:46 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-02-07 22:12:46 (GMT)
commitbbbac2ec34e99c24d7bc0eedbcc138c5f4551d48 (patch)
treed78b2fead0311d37b6f76d0a3466fd78196c8c31 /Objects
parent2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb (diff)
downloadcpython-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.zip
cpython-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.tar.gz
cpython-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.tar.bz2
Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index abe793d..51160f8 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));