diff Objects/unicodeobject.c @ 81326:3570e04f4ea9 2.7

Fix out of bound read in UTF-32 decoder on "narrow Unicode" builds.
author Serhiy Storchaka <storchaka@gmail.com>
date Tue, 08 Jan 2013 22:43:18 +0200
parents c7ce91756472
children f2353e74b335
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Tue Jan 08 19:47:00 2013 +0100
+++ b/Objects/unicodeobject.c	Tue Jan 08 22:43:18 2013 +0200
@@ -2272,7 +2272,7 @@
     /* On narrow builds we split characters outside the BMP into two
        codepoints => count how much extra space we need. */
 #ifndef Py_UNICODE_WIDE
-    for (qq = q; qq < e; qq += 4)
+    for (qq = q; e - qq >= 4; qq += 4)
         if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0)
             pairs++;
 #endif