mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
PyUnicode_CopyCharacters() fails if 'to' has more than 1 reference
This commit is contained in:
parent
7c8c1ea3ec
commit
f5ca1a21a5
2 changed files with 10 additions and 1 deletions
|
@ -631,6 +631,14 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
|
|||
how_many, to_start, PyUnicode_GET_LENGTH(to));
|
||||
return -1;
|
||||
}
|
||||
if (how_many == 0)
|
||||
return 0;
|
||||
|
||||
if (Py_REFCNT(to) != 1) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"Cannot modify a string having more than 1 reference");
|
||||
return -1;
|
||||
}
|
||||
|
||||
from_kind = PyUnicode_KIND(from);
|
||||
to_kind = PyUnicode_KIND(to);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue