]> granicus.if.org Git - python/commitdiff
Issue #28648: Fixed crash in Py_DecodeLocale() in debug build on Mac OS X
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 12 Nov 2016 12:28:06 +0000 (14:28 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 12 Nov 2016 12:28:06 +0000 (14:28 +0200)
when decode astral characters.

Misc/NEWS
Objects/unicodeobject.c

index c55dc4a2e015cba0bf73b9ef2e55e7a1930d1a49..d3489d1ecf95507642e799ad4fd360a97c8f484e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3.7?
 Core and Builtins
 -----------------
 
+- Issue #28648: Fixed crash in Py_DecodeLocale() in debug build on Mac OS X
+  when decode astral characters.  Patch by Xiang Zhang.
+
 - Issue #26171: Fix possible integer overflow and heap corruption in
   zipimporter.get_data().
 
index cf4f8421eb63dda2a0a596381414cbcdd3ce867b..24eda6be9bfbd41ddb2cc8cf5a7e978437b170a9 100644 (file)
@@ -4896,7 +4896,7 @@ _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size)
 #if SIZEOF_WCHAR_T == 4
             assert(0);
 #else
-            assert(Py_UNICODE_IS_SURROGATE(ch));
+            assert(ch > 0xFFFF && ch <= MAX_UNICODE);
             /*  compute and append the two surrogates: */
             unicode[outpos++] = (wchar_t)Py_UNICODE_HIGH_SURROGATE(ch);
             unicode[outpos++] = (wchar_t)Py_UNICODE_LOW_SURROGATE(ch);