mirror of
https://github.com/python/cpython.git
synced 2025-08-26 11:45:20 +00:00
[3.13] gh-127903: Fix a crash on debug builds when calling Objects/unicodeobject::_copy_characters
(GH-127876) (#128458)
gh-127903: Fix a crash on debug builds when calling `Objects/unicodeobject::_copy_characters`` (GH-127876)
(cherry picked from commit 46cb6340d7
)
Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
This commit is contained in:
parent
f8b24cdbb9
commit
b875917e21
3 changed files with 15 additions and 3 deletions
|
@ -1495,11 +1495,14 @@ _copy_characters(PyObject *to, Py_ssize_t to_start,
|
|||
assert(PyUnicode_Check(from));
|
||||
assert(from_start + how_many <= PyUnicode_GET_LENGTH(from));
|
||||
|
||||
assert(PyUnicode_Check(to));
|
||||
assert(to_start + how_many <= PyUnicode_GET_LENGTH(to));
|
||||
assert(to == NULL || PyUnicode_Check(to));
|
||||
|
||||
if (how_many == 0)
|
||||
if (how_many == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(to != NULL);
|
||||
assert(to_start + how_many <= PyUnicode_GET_LENGTH(to));
|
||||
|
||||
from_kind = PyUnicode_KIND(from);
|
||||
from_data = PyUnicode_DATA(from);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue