From: Pip Cet Date: Sun, 27 Sep 2020 15:40:07 +0000 (+0200) Subject: Fix more single-byte accesses caused by bytepos/charpos confusion X-Git-Tag: emacs-28.0.90~5848 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a492013d07c59fab8eb9779924b384181e878a1a;p=emacs.git Fix more single-byte accesses caused by bytepos/charpos confusion * src/cmds.c (internal_self_insert): Use FETCH_BYTE, not FETCH_CHAR, for a decremented byte position (bug#41520). * src/xdisp.c (Fwindow_text_pixel_size, trailing_whitespace_p): Ditto. --- diff --git a/src/cmds.c b/src/cmds.c index 90526612b7a..c29cf00dad1 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -390,7 +390,7 @@ internal_self_insert (int c, EMACS_INT n) by spaces so that the remaining text won't move. */ ptrdiff_t actual = PT_BYTE; actual -= prev_char_len (actual); - if (FETCH_CHAR (actual) == '\t') + if (FETCH_BYTE (actual) == '\t') /* Rather than add spaces, let's just keep the tab. */ chars_to_delete--; else diff --git a/src/xdisp.c b/src/xdisp.c index 3d40878be65..ecd23e0d0fc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10619,7 +10619,7 @@ include the height of both, if present, in the return value. */) while (bpos > BEGV_BYTE) { dec_both (&start, &bpos); - c = FETCH_CHAR (bpos); + c = FETCH_BYTE (bpos); if (!(c == ' ' || c == '\t')) break; } @@ -10641,7 +10641,7 @@ include the height of both, if present, in the return value. */) while (bpos > BEGV_BYTE) { dec_both (&end, &bpos); - c = FETCH_CHAR (bpos); + c = FETCH_BYTE (bpos); if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) break; } @@ -22277,7 +22277,7 @@ trailing_whitespace_p (ptrdiff_t charpos) int c = 0; while (bytepos < ZV_BYTE - && (c = FETCH_CHAR (bytepos), + && (c = FETCH_BYTE (bytepos), c == ' ' || c == '\t')) ++bytepos;