mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
_PyUnicode_CheckConsistency() ensures that the unicode string ends with a
null character
This commit is contained in:
parent
3065093bb3
commit
718fbf078c
1 changed files with 6 additions and 2 deletions
|
@ -375,10 +375,13 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
Py_UCS4 maxchar = 0;
|
Py_UCS4 maxchar = 0;
|
||||||
void *data = PyUnicode_DATA(ascii);
|
void *data;
|
||||||
|
Py_UCS4 ch;
|
||||||
|
|
||||||
|
data = PyUnicode_DATA(ascii);
|
||||||
for (i=0; i < ascii->length; i++)
|
for (i=0; i < ascii->length; i++)
|
||||||
{
|
{
|
||||||
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
|
ch = PyUnicode_READ(kind, data, i);
|
||||||
if (ch > maxchar)
|
if (ch > maxchar)
|
||||||
maxchar = ch;
|
maxchar = ch;
|
||||||
}
|
}
|
||||||
|
@ -398,6 +401,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
|
||||||
assert(maxchar >= 0x10000);
|
assert(maxchar >= 0x10000);
|
||||||
assert(maxchar <= MAX_UNICODE);
|
assert(maxchar <= MAX_UNICODE);
|
||||||
}
|
}
|
||||||
|
assert(PyUnicode_READ(kind, data, ascii->length) == 0);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue