From: Alan Mackenzie Date: Sat, 2 Mar 2019 18:23:34 +0000 (+0000) Subject: Check by eassert that a bytepos argument isn't in the middle of a character X-Git-Tag: emacs-27.0.90~3500 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=954c9c5bc344cdd6b201c2260b306ec0999aff24;p=emacs.git Check by eassert that a bytepos argument isn't in the middle of a character * src/marker.c (buf_bytepos_to_charpos): Add an eassert to check that the parameter bytepos is at the beginning of a character or EOB. --- diff --git a/src/marker.c b/src/marker.c index b58051a8c2b..0b2e1bf5c6b 100644 --- a/src/marker.c +++ b/src/marker.c @@ -332,6 +332,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) if (best_above == best_above_byte) return bytepos; + /* Check bytepos is not in the middle of a character. */ + eassert (bytepos >= BUF_Z_BYTE (b) + || CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos))); + best_below = BEG; best_below_byte = BEG_BYTE;