imwayland: Honour len argument in gtk_im_context_wayland_set_surrounding

Clients may pass not `NULL`-terminated strings as the function takes a
`len` argument. Use that argument.
This commit is contained in:
Robert Mader 2020-03-16 16:26:48 +01:00
parent 88e71646de
commit 3c28751dee
2 changed files with 2 additions and 2 deletions

View File

@ -828,7 +828,7 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
g_free (context_wayland->surrounding.text);
context_wayland->surrounding.text = g_strdup (text);
context_wayland->surrounding.text = g_strndup (text, len);
context_wayland->surrounding.cursor_idx = cursor_index;
/* Anchor is not exposed via the set_surrounding interface, emulating. */
context_wayland->surrounding.anchor_idx = cursor_index;

View File

@ -598,7 +598,7 @@ gtk_im_context_wayland_set_surrounding (GtkIMContext *context,
context_wayland = GTK_IM_CONTEXT_WAYLAND (context);
g_free (context_wayland->surrounding.text);
context_wayland->surrounding.text = g_strdup (text);
context_wayland->surrounding.text = g_strndup (text, len);
context_wayland->surrounding.cursor_idx = cursor_index;
notify_surrounding_text (context_wayland);