[gnome-flashback/gnome-3-22] input-sources: avoid crash in make_engine_short_name
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback/gnome-3-22] input-sources: avoid crash in make_engine_short_name
- Date: Mon, 13 Mar 2017 16:29:44 +0000 (UTC)
commit 117d541ac2821a7943311c8622c86c0172c52f09
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Mar 13 18:29:32 2017 +0200
input-sources: avoid crash in make_engine_short_name
.../libinput-sources/gf-input-source-manager.c | 27 +++++++++++--------
1 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-input-source-manager.c
b/gnome-flashback/libinput-sources/gf-input-source-manager.c
index 224e3b7..73d46d1 100644
--- a/gnome-flashback/libinput-sources/gf-input-source-manager.c
+++ b/gnome-flashback/libinput-sources/gf-input-source-manager.c
@@ -366,28 +366,33 @@ static gchar *
make_engine_short_name (IBusEngineDesc *engine_desc)
{
const gchar *symbol;
- const gchar *language_code;
- gchar **codes;
+ const gchar *language;
symbol = ibus_engine_desc_get_symbol (engine_desc);
if (symbol != NULL && symbol[0] != '\0')
return g_strdup (symbol);
- language_code = ibus_engine_desc_get_language (engine_desc);
- codes = g_strsplit (language_code, "_", 2);
+ language = ibus_engine_desc_get_language (engine_desc);
- if (strlen (codes[0]) == 2 || strlen (codes[0]) == 3)
+ if (language != NULL && language[0] != '\0')
{
- gchar *short_name;
+ gchar **codes;
- short_name = g_ascii_strdown (codes[0], -1);
- g_strfreev (codes);
+ codes = g_strsplit (language, "_", 2);
- return short_name;
- }
+ if (strlen (codes[0]) == 2 || strlen (codes[0]) == 3)
+ {
+ gchar *short_name;
+
+ short_name = g_ascii_strdown (codes[0], -1);
+ g_strfreev (codes);
- g_strfreev (codes);
+ return short_name;
+ }
+
+ g_strfreev (codes);
+ }
return get_symbol_from_char_code (0x2328);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]