summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-08-01 08:49:18 (GMT)
committerGeorg Brandl <georg@python.org>2010-08-01 08:49:18 (GMT)
commitbd534f03498c97273dc5bf00182e6405a3a92e01 (patch)
treef06866db483522693570fa00a07d653fc3b6b39b /Objects/unicodeobject.c
parent9411eeb522980f6239e5466a23417cdd8e6149a1 (diff)
downloadcpython-bd534f03498c97273dc5bf00182e6405a3a92e01.zip
cpython-bd534f03498c97273dc5bf00182e6405a3a92e01.tar.gz
cpython-bd534f03498c97273dc5bf00182e6405a3a92e01.tar.bz2
#8821: do not rely on Unicode strings being terminated with a \u0000, rather explicitly check range before looking for a second surrogate character.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index f2d666d..bfd19eb 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3734,7 +3734,7 @@ PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s,
ch2 = *s++;
size--;
- if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
+ if (ch2 >= 0xDC00 && ch2 <= 0xDFFF && size) {
ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000;
*p++ = '\\';
*p++ = 'U';
@@ -3976,7 +3976,7 @@ PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s,
ch2 = *s++;
size--;
- if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
+ if (ch2 >= 0xDC00 && ch2 <= 0xDFFF && size) {
ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000;
*p++ = '\\';
*p++ = 'U';