From 3c28751dee115e969a58a733f2f19e71062b9d2d Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Mon, 16 Mar 2020 16:26:48 +0100 Subject: [PATCH] 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. --- modules/input/imwayland.c | 2 +- modules/input/imwaylandgtk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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);