diff --git a/modules/input/imwayland.c b/modules/input/imwayland.c index 199714d046..821f2f678c 100644 --- a/modules/input/imwayland.c +++ b/modules/input/imwayland.c @@ -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; diff --git a/modules/input/imwaylandgtk.c b/modules/input/imwaylandgtk.c index 58a5e48c29..207891d502 100644 --- a/modules/input/imwaylandgtk.c +++ b/modules/input/imwaylandgtk.c @@ -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);