diff options
author | Akira TAGOH <akira@tagoh.org> | 2015-12-01 17:05:55 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2015-12-01 17:14:55 +0900 |
commit | 57e8775ca8fe0fbe688896e017a1f0b10c88277a (patch) | |
tree | 3c2d3dbfb97b292c94178d1a5332ef4a4aabcde3 | |
parent | 3a29458f9adc0fc5b874142c76efbad5a2a785b1 (diff) |
Fix a segfault if no territory or script is given to lt_tag_convert_from_locale_string()
-rw-r--r-- | liblangtag/lt-tag.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/liblangtag/lt-tag.c b/liblangtag/lt-tag.c index dba8547..6b2f3a3 100644 --- a/liblangtag/lt-tag.c +++ b/liblangtag/lt-tag.c @@ -1129,8 +1129,8 @@ _lt_tag_convert_from_locale_string(const char *locale, s = strdup(locale); tag = lt_tag_new(); if (!s || s[0] == 0 || - lt_strcmp0(s, "C") == 0 || - lt_strcmp0(s, "POSIX") == 0) { + lt_strcasecmp(s, "C") == 0 || + lt_strcasecmp(s, "POSIX") == 0) { if (!lt_tag_parse(tag, "en-US-u-va-posix", &err)) goto bail; } else { @@ -1152,13 +1152,16 @@ _lt_tag_convert_from_locale_string(const char *locale, if (p) { *p = 0; p++; - } - /* For platforms where represent locale as BCP47 */ - territory = strchr(p, '_'); - if (territory) { - *territory = 0; - territory++; - script = p; + + /* For platforms where represent locale as BCP47 */ + territory = strchr(p, '_'); + if (territory) { + *territory = 0; + territory++; + script = p; + } else { + territory = p; + } } else { territory = p; } |