diff Objects/unicodeobject.c @ 81327:bf347198fbaf 3.2

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:45:42 +0200
parents c256764e2b3f
children 4677c5f6fcf7 cd36e961e42c
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Tue Jan 08 19:49:42 2013 +0100
+++ b/Objects/unicodeobject.c	Tue Jan 08 22:45:42 2013 +0200
@@ -3182,7 +3182,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