summaryrefslogtreecommitdiffstats
path: root/intl/icu-patches/bug-1792775-ICU-22198.diff
blob: ec5211b651625d5948124955e9047057dde4442b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# https://github.com/unicode-org/icu/pull/2248
# https://github.com/unicode-org/icu/pull/2248.diff
#
# ICU bug: https://unicode-org.atlassian.net/browse/ICU-22198

diff --git a/intl/icu/source/common/uresbund.cpp b/intl/icu/source/common/uresbund.cpp
index 17c0177a05c..81fb90e1384 100644
--- a/intl/icu/source/common/uresbund.cpp
+++ b/intl/icu/source/common/uresbund.cpp
@@ -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);
     }