From cbbe647bb78886d841d4dc0b7827e29b059b3451 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Mon, 5 Jun 2006 10:43:57 +0000 Subject: [PATCH] Don't crash on Py_UNICODE values < 0. Fixes #1454485. --- Misc/NEWS | 2 ++ Objects/unicodeobject.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 3171e036593f..cac884c98dad 100644 --- 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 diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 5fce3f91c729..7c69d68a9d33 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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); -- 2.47.3