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
This commit is contained in:
Luca Bacci 2023-10-18 16:02:03 +02:00
parent 30d7f33579
commit f003609d35

View File

@ -336,6 +336,9 @@ gtk_im_context_ime_filter_keypress (GtkIMContext *context,
return FALSE; return FALSE;
utf8 = g_utf16_to_utf8 (event_priv->translation, event_priv->translation_len, NULL, NULL, NULL); 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_signal_emit_by_name (context_ime, "commit", utf8);
g_free (utf8); g_free (utf8);