Skip to content

Commit 336ab4b

Browse files
committed
- setlocale(LC_CTYPE, "") returns null when omc is launched via double clicking on OMEdit.app. This results in strdup(null) which leads to omc crash. Just check if setlocale(LC_CTYPE, "") is not null then use it otherwise use the default value.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16694 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent a11f647 commit 336ab4b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Compiler/runtime/systemimpl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,10 @@ void SystemImpl__gettextInit(const char *locale)
18641864
int locale_len = strlen(locale);
18651865
char *locale2 = alloc_locale_str(locale, locale_len, ".utf8", 5);
18661866
char *locale3 = alloc_locale_str(locale, locale_len, ".UTF-8", 6);
1867-
char *old_ctype = strdup(setlocale(LC_CTYPE, ""));
1867+
char *old_ctype_default = "UTF-8";
1868+
if (setlocale(LC_CTYPE, ""))
1869+
old_ctype_default = setlocale(LC_CTYPE, "");
1870+
char *old_ctype = strdup(old_ctype_default);
18681871
int old_ctype_is_utf8 = strcmp(nl_langinfo(CODESET), "UTF-8") == 0;
18691872

18701873
int res = *locale == 0 ? setlocale(LC_MESSAGES, "") && setlocale(LC_CTYPE, ""):

0 commit comments

Comments
 (0)