]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Special case normalization of empty strings. Fixes #924361.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 17 Apr 2004 19:36:13 +0000 (19:36 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 17 Apr 2004 19:36:13 +0000 (19:36 +0000)
Misc/NEWS
Modules/unicodedata.c

index 792b41066affb543a8180bcf270aba2f360a8ef9..8d73eab69d875e47cd6501c08853f84e8400889d 100644 (file)
--- 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.
 
index 311db296bdbcecacdef9c44e98be8ae79ef45fe1..ba218a3e58e89fd34be5246da348de62b12fe267 100644 (file)
@@ -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)