[epiphany] gnome-languages: fix crashes on unexpected locales
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] gnome-languages: fix crashes on unexpected locales
- Date: Thu, 7 Mar 2019 16:30:41 +0000 (UTC)
commit 471c536bafd8e8f24de76d369bfe5b8d6c67272e
Author: Michael Catanzaro <mcatanzaro posteo net>
Date: Thu Mar 7 16:30:32 2019 +0000
gnome-languages: fix crashes on unexpected locales
I forgot to error-check the result of newlocale to make sure it's really
a valid locale.
lib/contrib/gnome-languages.c | 4 ++++
src/prefs-dialog.c | 2 ++
2 files changed, 6 insertions(+)
---
diff --git a/lib/contrib/gnome-languages.c b/lib/contrib/gnome-languages.c
index b754229e6..d663c1507 100644
--- a/lib/contrib/gnome-languages.c
+++ b/lib/contrib/gnome-languages.c
@@ -710,6 +710,8 @@ get_translated_language (const char *code,
if (locale != NULL) {
loc = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
+ if (loc == (locale_t) 0)
+ return NULL;
old_locale = uselocale (loc);
}
@@ -767,6 +769,8 @@ get_translated_territory (const char *code,
if (locale != NULL) {
loc = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
+ if (loc == (locale_t) 0)
+ return NULL;
old_locale = uselocale (loc);
}
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 9ef2e5515..bd36daccb 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1600,6 +1600,8 @@ create_language_section (PrefsDialog *dialog)
g_autofree char *normalized_locale = normalize_locale (code);
if (normalized_locale != NULL) {
g_autofree char *language_name = language_for_locale (normalized_locale);
+ if (language_name == NULL)
+ language_name = g_strdup (normalized_locale);
language_editor_add (dialog, normalized_locale, language_name);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]