summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-27 15:56:53 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-27 15:56:53 (GMT)
commit5bc03a6d4d5d08663056ad1e85b67ad53e74d795 (patch)
tree1e07cdd7be1ba1978dacc5f7c55f3c5374d7f7bf /Objects
parent3743432302e9b31d4fe0db31485543a306057fc8 (diff)
downloadcpython-5bc03a6d4d5d08663056ad1e85b67ad53e74d795.zip
cpython-5bc03a6d4d5d08663056ad1e85b67ad53e74d795.tar.gz
cpython-5bc03a6d4d5d08663056ad1e85b67ad53e74d795.tar.bz2
Fix resize_compact()
Issue #26217: resize_compact() must set wstr_length to 0 after freeing the wstr string. Otherwise, an assertion fails in _PyUnicode_CheckConsistency().
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index c957929..d4c9aae 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -748,6 +748,8 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
+ if (!PyUnicode_IS_ASCII(unicode))
+ _PyUnicode_WSTR_LENGTH(unicode) = 0;
}
#ifdef Py_DEBUG
unicode_fill_invalid(unicode, old_length);