]> granicus.if.org Git - icu/commitdiff
ICU-22198 Fix stack buffer overflow.
authorEli Kobrin <kobrineli@ispras.ru>
Thu, 3 Nov 2022 15:25:33 +0000 (18:25 +0300)
committerRich Gillam <62772518+richgillam@users.noreply.github.com>
Wed, 16 Nov 2022 19:29:32 +0000 (11:29 -0800)
icu4c/source/common/uresbund.cpp

index 17c0177a05cb5ec9f4b0cc57956885b72965df8a..81fb90e138464fafb99c4bdde4c2b8930c2c3ba2 100644 (file)
@@ -202,7 +202,8 @@ typedef enum UResOpenType UResOpenType;
  */
 static bool getParentLocaleID(char *name, const char *origName, UResOpenType openType) {
     // early out if the locale ID has a variant code or ends with _
-    if (name[uprv_strlen(name) - 1] == '_' || hasVariant(name)) {
+    size_t nameLen = uprv_strlen(name);
+    if (!nameLen || name[nameLen - 1] == '_' || hasVariant(name)) {
         return chopLocale(name);
     }