Skip to content

Commit 7618a2b

Browse files
committed
Use resize_copy as fallback logic
1 parent 6ca1abb commit 7618a2b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Objects/unicodeobject.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,13 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
11661166
#endif
11671167

11681168
if (!unicode_modifiable(unicode)) {
1169-
return resize_copy(unicode, length);
1169+
PyObject *copy = resize_copy(unicode, length);
1170+
if (copy == NULL) {
1171+
PyErr_NoMemory();
1172+
return NULL;
1173+
}
1174+
Py_DECREF(unicode);
1175+
return copy;
11701176
}
11711177
assert(PyUnicode_IS_COMPACT(unicode));
11721178

0 commit comments

Comments
 (0)