From 4e04c396095b7e4b70f0635ded6241a61a62ada8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 15 Oct 2020 15:16:06 -0400 Subject: [PATCH] emojicompletion: Avoid a memory overrun Don't read beyond the beginning of the string. Fixes: #3245 --- gtk/gtkemojicompletion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c index 712418850a..31669c85d5 100644 --- a/gtk/gtkemojicompletion.c +++ b/gtk/gtkemojicompletion.c @@ -115,7 +115,8 @@ next: break; } } - while (g_unichar_isalnum (g_utf8_get_char (p)) || *p == '_' || *p == ' '); + while (p > text && + (g_unichar_isalnum (g_utf8_get_char (p)) || *p == '_' || *p == ' ')); if (found_candidate) n_matches = populate_completion (completion, p, 0);