From f003609d3502efa022dc9c1d2eee14e995eabdbb Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 18 Oct 2023 16:02:03 +0200 Subject: [PATCH] GtkIMContextIME: Avoid committing NULL string We may get invalid UTF-16 sequences when third party apps or hooks inject WM_CHAR messages. Validate the unicode string before committing. Fixes https://gitlab.com/inkscape/inkscape/-/issues/2088 --- modules/input/gtkimcontextime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/input/gtkimcontextime.c b/modules/input/gtkimcontextime.c index 30c56c59cd..5bc65793e2 100644 --- a/modules/input/gtkimcontextime.c +++ b/modules/input/gtkimcontextime.c @@ -336,6 +336,9 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context, return FALSE; utf8 = g_utf16_to_utf8 (event_priv->translation, event_priv->translation_len, NULL, NULL, NULL); + if (!utf8) + return FALSE; + g_signal_emit_by_name (context_ime, "commit", utf8); g_free (utf8);