Skip to content

Commit

Permalink
unicode_resize() clears embed_null cache
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Nov 1, 2023
1 parent 3c4844f commit e224751
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
_PyUnicode_STATE(unicode).embed_null = EMBED_NULL_UNKNOWN;
#ifdef Py_TRACE_REFS
_Py_ForgetReference(unicode);
#endif
Expand Down Expand Up @@ -1068,6 +1069,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
_PyUnicode_STATE(unicode).embed_null = EMBED_NULL_UNKNOWN;

data = (PyObject *)PyObject_Realloc(data, new_size);
if (data == NULL) {
Expand Down Expand Up @@ -11082,6 +11084,7 @@ PyUnicode_Append(PyObject **p_left, PyObject *right)
Py_DECREF(left);
*p_left = res;
}
assert(_PyUnicode_STATE(*p_left).embed_null == EMBED_NULL_UNKNOWN);
assert(_PyUnicode_CheckConsistency(*p_left, 1));
return;

Expand Down

0 comments on commit e224751

Please sign in to comment.