Skip to content

Commit 718fbf0

Browse files
committed
_PyUnicode_CheckConsistency() ensures that the unicode string ends with a
null character
1 parent 3065093 commit 718fbf0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,13 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
375375
{
376376
Py_ssize_t i;
377377
Py_UCS4 maxchar = 0;
378-
void *data = PyUnicode_DATA(ascii);
378+
void *data;
379+
Py_UCS4 ch;
380+
381+
data = PyUnicode_DATA(ascii);
379382
for (i=0; i < ascii->length; i++)
380383
{
381-
Py_UCS4 ch = PyUnicode_READ(kind, data, i);
384+
ch = PyUnicode_READ(kind, data, i);
382385
if (ch > maxchar)
383386
maxchar = ch;
384387
}
@@ -398,6 +401,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
398401
assert(maxchar >= 0x10000);
399402
assert(maxchar <= MAX_UNICODE);
400403
}
404+
assert(PyUnicode_READ(kind, data, ascii->length) == 0);
401405
}
402406
return 1;
403407
}

0 commit comments

Comments
 (0)