Commit 5bc03a6d authored by Victor Stinner's avatar Victor Stinner

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().
parent 37434323
...@@ -748,6 +748,8 @@ resize_compact(PyObject *unicode, Py_ssize_t length) ...@@ -748,6 +748,8 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) { else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_WSTR(unicode)); PyObject_DEL(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL; _PyUnicode_WSTR(unicode) = NULL;
if (!PyUnicode_IS_ASCII(unicode))
_PyUnicode_WSTR_LENGTH(unicode) = 0;
} }
#ifdef Py_DEBUG #ifdef Py_DEBUG
unicode_fill_invalid(unicode, old_length); unicode_fill_invalid(unicode, old_length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment