diff options
author | Georg Brandl <georg@python.org> | 2010-08-01 18:41:59 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-08-01 18:41:59 (GMT) |
commit | 09f0d60f7cc08746511bb957c518885ee0421363 (patch) | |
tree | ccb0712b1de5cc9ed03ce1459060a4a0bfc0dad2 | |
parent | 607951d405d7afd8a17408aa9c0e10f44f505c8c (diff) | |
download | cpython-09f0d60f7cc08746511bb957c518885ee0421363.zip cpython-09f0d60f7cc08746511bb957c518885ee0421363.tar.gz cpython-09f0d60f7cc08746511bb957c518885ee0421363.tar.bz2 |
Merged revisions 83395 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83395 | georg.brandl | 2010-08-01 10:49:18 +0200 (So, 01 Aug 2010) | 1 line
#8821: do not rely on Unicode strings being terminated with a \u0000, rather explicitly check range before looking for a second surrogate character.
........
-rw-r--r-- | Objects/unicodeobject.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 81b62e4..42e0c9f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3067,7 +3067,7 @@ PyObject *unicodeescape_string(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'; @@ -3316,7 +3316,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'; |