From fb739ee2f83df58266c8bfc6a0e4426fed5b5890 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 4 Jun 2016 09:02:20 -0400 Subject: [PATCH] Fbackward_prefix_chars: stay within buffer bounds The commit 1fd3172d "(Fbackward_prefix_chars): Set point properly while scanning" (1998-03-18), moved the check against of the position against the buffer beginning out the loop condition so that we might end up checking the syntax of characters before the beginning of the buffer. This can cause segfaults or trigger a "Point before start of properties" error in `update_interval' (called indirectly from `char_quoted'). * src/syntax.c (Fbackward_prefix_chars): Stop the loop when beginning of buffer is reached (Bug #3552). --- src/syntax.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/syntax.c b/src/syntax.c index 8e14bf3..b1ba5c6 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -3109,8 +3109,9 @@ DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars, opoint = pos; opoint_byte = pos_byte; - if (pos + 1 > beg) - DEC_BOTH (pos, pos_byte); + if (pos <= beg) + break; + DEC_BOTH (pos, pos_byte); } SET_PT_BOTH (opoint, opoint_byte); -- 2.8.0