Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5bc03a6

Browse files
committed
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().
1 parent 3743432 commit 5bc03a6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Objects/unicodeobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
748748
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
749749
PyObject_DEL(_PyUnicode_WSTR(unicode));
750750
_PyUnicode_WSTR(unicode) = NULL;
751+
if (!PyUnicode_IS_ASCII(unicode))
752+
_PyUnicode_WSTR_LENGTH(unicode) = 0;
751753
}
752754
#ifdef Py_DEBUG
753755
unicode_fill_invalid(unicode, old_length);

0 commit comments

Comments
 (0)