summaryrefslogtreecommitdiff
path: root/gtk/gtkimcontextwayland.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-04-03 12:44:37 +0200
committerCarlos Garnacho <carlosg@gnome.org>2020-04-03 19:55:55 +0200
commite5d23aaaaf352748e6411cfd399d4b741be9d478 (patch)
tree2fea64e043523070c4e36b5bfb6f79502eea93e2 /gtk/gtkimcontextwayland.c
parentde481a7b5e7730cf47156c40c88c446e4b762d94 (diff)
downloadgtk+-e5d23aaaaf352748e6411cfd399d4b741be9d478.tar.gz
imwayland: Clamp the surrounding string end correctly
In the paths where len > MAX_LEN and cursor/anchor are separated by at least MAX_LEN from text edges, we were clamping the right end of the surrounding string at MAX_LEN. Oops. This end anchor may go as far as the string length, although just up to len - MAX_LEN in real terms (due to the condition above that caches cursor/anchor positions being near enough the text end). Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2565 (cherry-picked from commit d7fb15c822eabe22ffda19892153d69b0f4fc2f3)
Diffstat (limited to 'gtk/gtkimcontextwayland.c')
-rw-r--r--gtk/gtkimcontextwayland.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 2462f7201f..6c3b2b393a 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -323,7 +323,7 @@ notify_surrounding_text (GtkIMContextWayland *context)
mid = MIN (context->surrounding.cursor_idx,
context->surrounding.anchor_idx) + (cursor_len / 2);
a = MAX (0, mid - (MAX_LEN / 2));
- b = MIN (MAX_LEN, mid + (MAX_LEN / 2));
+ b = MIN (len, mid + (MAX_LEN / 2));
start = &context->surrounding.text[a];
end = &context->surrounding.text[b];