summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-04-25 22:39:37 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-04-25 22:39:37 (GMT)
commit718fbf078cef405318dc712a2c32fbc12e87de02 (patch)
tree5996d0e8ebd9f07eec739bedd068ae65203ee51c /Objects
parent3065093bb3798b6a4491f9c4a3bb6c10724a143b (diff)
downloadcpython-718fbf078cef405318dc712a2c32fbc12e87de02.zip
cpython-718fbf078cef405318dc712a2c32fbc12e87de02.tar.gz
cpython-718fbf078cef405318dc712a2c32fbc12e87de02.tar.bz2
_PyUnicode_CheckConsistency() ensures that the unicode string ends with a
null character
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7efa939..364de90 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -375,10 +375,13 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
{
Py_ssize_t i;
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++)
{
- Py_UCS4 ch = PyUnicode_READ(kind, data, i);
+ ch = PyUnicode_READ(kind, data, i);
if (ch > maxchar)
maxchar = ch;
}
@@ -398,6 +401,7 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content)
assert(maxchar >= 0x10000);
assert(maxchar <= MAX_UNICODE);
}
+ assert(PyUnicode_READ(kind, data, ascii->length) == 0);
}
return 1;
}