From a2f79361f8472877c79fbb7bd70615eb2e5b918f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sat, 17 Apr 2004 19:36:13 +0000 Subject: [PATCH] Special case normalization of empty strings. Fixes #924361. --- Misc/NEWS | 2 ++ Modules/unicodedata.c | 7 +++++++ 2 files changed, 9 insertions(+) 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) -- 2.47.3