diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2009-02-25 18:32:49 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2009-02-25 18:32:49 +0800 |
commit | f3eb21d578df711c707a333714d7e05a50d7e39c (patch) | |
tree | fd53bc10062b616eb5ee2d499cd05f993bb1384e /src/ibustext.c | |
parent | 1afc03e795559a06be1ed117fa2e8c52db016b66 (diff) | |
download | ibus-f3eb21d578df711c707a333714d7e05a50d7e39c.tar.gz ibus-f3eb21d578df711c707a333714d7e05a50d7e39c.tar.xz ibus-f3eb21d578df711c707a333714d7e05a50d7e39c.zip |
Check ucs4 and unichar when create IBusText object.
Diffstat (limited to 'src/ibustext.c')
-rw-r--r-- | src/ibustext.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ibustext.c b/src/ibustext.c index 1725dda..362ce82 100644 --- a/src/ibustext.c +++ b/src/ibustext.c @@ -190,11 +190,18 @@ ibus_text_new_from_ucs4 (const gunichar *str) g_return_val_if_fail (str != NULL, NULL); IBusText *text; + gchar *buf; + + buf = g_ucs4_to_utf8 (str, -1, NULL, NULL, NULL); + + if (buf == NULL) { + return NULL; + } text= g_object_new (IBUS_TYPE_TEXT, NULL); text->is_static = FALSE; - text->text = g_ucs4_to_utf8 (str, -1, NULL, NULL, NULL); + text->text = buf; return text; } @@ -244,6 +251,10 @@ ibus_text_new_from_unichar (gunichar c) IBusText *text; gint len; + if (!g_unichar_validate (c)) { + return NULL; + } + text= g_object_new (IBUS_TYPE_TEXT, NULL); text->text = (gchar *)g_malloc (12); @@ -251,7 +262,6 @@ ibus_text_new_from_unichar (gunichar c) text->text[len] = 0; return text; - } void |