Fix resize_inplace(): update shared utf8 pointer

This commit is contained in:
Victor Stinner 2011-10-03 12:11:00 +02:00
parent ca4f7a4298
commit 1c8d0c76a1

View File

@ -443,13 +443,14 @@ resize_inplace(register PyUnicodeObject *unicode, Py_ssize_t length)
if (PyUnicode_IS_READY(unicode)) { if (PyUnicode_IS_READY(unicode)) {
Py_ssize_t char_size; Py_ssize_t char_size;
Py_ssize_t new_size; Py_ssize_t new_size;
int share_wstr; int share_wstr, share_utf8;
void *data; void *data;
data = _PyUnicode_DATA_ANY(unicode); data = _PyUnicode_DATA_ANY(unicode);
assert(data != NULL); assert(data != NULL);
char_size = PyUnicode_CHARACTER_SIZE(unicode); char_size = PyUnicode_CHARACTER_SIZE(unicode);
share_wstr = (_PyUnicode_WSTR(unicode) == data); share_wstr = (_PyUnicode_WSTR(unicode) == data);
share_utf8 = (_PyUnicode_UTF8(unicode) == data);
if (length > (PY_SSIZE_T_MAX / char_size - 1)) { if (length > (PY_SSIZE_T_MAX / char_size - 1)) {
PyErr_NoMemory(); PyErr_NoMemory();
@ -465,6 +466,8 @@ resize_inplace(register PyUnicodeObject *unicode, Py_ssize_t length)
_PyUnicode_DATA_ANY(unicode) = data; _PyUnicode_DATA_ANY(unicode) = data;
if (share_wstr) if (share_wstr)
_PyUnicode_WSTR(unicode) = data; _PyUnicode_WSTR(unicode) = data;
if (share_utf8)
_PyUnicode_UTF8(unicode) = data;
_PyUnicode_LENGTH(unicode) = length; _PyUnicode_LENGTH(unicode) = length;
PyUnicode_WRITE(PyUnicode_KIND(unicode), data, length, 0); PyUnicode_WRITE(PyUnicode_KIND(unicode), data, length, 0);
if (share_wstr) if (share_wstr)