From: Martin v. Löwis Date: Sat, 17 Apr 2004 19:36:13 +0000 (+0000) Subject: Special case normalization of empty strings. Fixes #924361. X-Git-Tag: v2.3.4c1~57 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2f79361f8472877c79fbb7bd70615eb2e5b918f;p=thirdparty%2FPython%2Fcpython.git Special case normalization of empty strings. Fixes #924361. --- diff --git a/Misc/NEWS b/Misc/NEWS index 792b41066aff..8d73eab69d87 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -42,6 +42,8 @@ Core and builtins Library ------- +- Bug #924361: Properly support normalization of empty unicode strings. + - Fixed a caching bug in platform.platform() where the argument of 'terse' was not taken into consideration when caching value. diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 311db296bdbc..ba218a3e58e8 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -515,6 +515,13 @@ unicodedata_normalize(PyObject *self, PyObject *args) &form, &PyUnicode_Type, &input)) return NULL; + if (PyUnicode_GetSize(input) == 0) { + /* Special case empty input strings, since resizing + them later would cause internal errors. */ + Py_INCREF(input); + return input; + } + if (strcmp(form, "NFC") == 0) return nfc_nfkc(input, 0); if (strcmp(form, "NFKC") == 0)