]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Don't crash on Py_UNICODE values < 0. Fixes #1454485.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 5 Jun 2006 10:43:57 +0000 (10:43 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 5 Jun 2006 10:43:57 +0000 (10:43 +0000)
Misc/NEWS
Objects/unicodeobject.c

index 3171e036593fc4709e1d5eb2ede6d35417d63d3d..cac884c98dad0f9e7c129ac0b562224844e36c51 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4.4c1?
 Core and builtins
 -----------------
 
+- Bug #1454485: Don't crash on Unicode characters <0.
+
 - Patch #1488312, Fix memory alignment problem on SPARC in unicode
 
 Extension Modules
index 5fce3f91c729233db5ed46ebee755867ed5ab1ee..7c69d68a9d33589b848200208a7659f2e85c7f9f 100644 (file)
@@ -319,7 +319,9 @@ PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u,
 
        /* Single character Unicode objects in the Latin-1 range are
           shared when using this constructor */
-       if (size == 1 && *u < 256) {
+       /* XXX In Python 2.4, Py_UNICODE can, unfortunately, be a signed
+          type. */
+       if (size == 1 && *u >= 0 && *u < 256) {
            unicode = unicode_latin1[*u];
            if (!unicode) {
                unicode = _PyUnicode_New(1);