[gnome-desktop] gnome-languages: Return early if the locale didn't parse correctly
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] gnome-languages: Return early if the locale didn't parse correctly
- Date: Mon, 11 Jan 2016 13:20:01 +0000 (UTC)
commit 571db6a870f3d83013d321745ac4e997f853a6c6
Author: Rui Matos <tiagomatos gmail com>
Date: Fri Jan 8 14:59:26 2016 +0100
gnome-languages: Return early if the locale didn't parse correctly
There's no point in going further if we can't parse the locale and
we can prevent crashes in some corner cases this way.
https://bugzilla.gnome.org/show_bug.cgi?id=760304
libgnome-desktop/gnome-languages.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
index 2ec97a5..d2d88ea 100644
--- a/libgnome-desktop/gnome-languages.c
+++ b/libgnome-desktop/gnome-languages.c
@@ -391,6 +391,7 @@ add_locale (const char *language_name,
GnomeLocale *old_locale;
char *name;
gboolean is_utf8 = FALSE;
+ gboolean valid = FALSE;
g_return_val_if_fail (language_name != NULL, FALSE);
g_return_val_if_fail (*language_name != '\0', FALSE);
@@ -426,13 +427,16 @@ add_locale (const char *language_name,
}
locale = g_new0 (GnomeLocale, 1);
- gnome_parse_locale (name,
- &locale->language_code,
- &locale->territory_code,
- &locale->codeset,
- &locale->modifier);
+ valid = gnome_parse_locale (name,
+ &locale->language_code,
+ &locale->territory_code,
+ &locale->codeset,
+ &locale->modifier);
g_free (name);
- name = NULL;
+ if (!valid) {
+ gnome_locale_free (locale);
+ return FALSE;
+ }
locale->id = construct_language_name (locale->language_code, locale->territory_code,
NULL, locale->modifier);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]