aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2021-02-24 17:55:28 +0200
committerEli Zaretskii2021-02-24 17:55:28 +0200
commitac45f314547ed9904ddc387157d3f4ba0c5fe1d2 (patch)
treeef5b72d3a0abf38f558ee8737214ce8e6e0c1916 /src
parenteef185dfc82330198b77b46cf7e48f8142c55ea2 (diff)
downloademacs-ac45f314547ed9904ddc387157d3f4ba0c5fe1d2.tar.gz
emacs-ac45f314547ed9904ddc387157d3f4ba0c5fe1d2.zip
Fix dangerous code in xdisp.c
* src/xdisp.c (move_it_to, display_line): Make sure ZV_BYTE is greater than 1 before fetching previous byte.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index cd3455aefcf..cc0a689ba32 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10052,7 +10052,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
10052 && (IT_CHARPOS (*it) > to_charpos 10052 && (IT_CHARPOS (*it) > to_charpos
10053 || (IT_CHARPOS (*it) == to_charpos 10053 || (IT_CHARPOS (*it) == to_charpos
10054 && to_charpos == ZV 10054 && to_charpos == ZV
10055 && FETCH_BYTE (ZV_BYTE - 1) != '\n'))) 10055 && (ZV_BYTE <= 1 || FETCH_BYTE (ZV_BYTE - 1) != '\n'))))
10056 { 10056 {
10057 reached = 9; 10057 reached = 9;
10058 goto out; 10058 goto out;
@@ -24118,7 +24118,8 @@ display_line (struct it *it, int cursor_vpos)
24118 the logical order. */ 24118 the logical order. */
24119 if (IT_BYTEPOS (*it) > BEG_BYTE) 24119 if (IT_BYTEPOS (*it) > BEG_BYTE)
24120 row->ends_at_zv_p = 24120 row->ends_at_zv_p =
24121 IT_BYTEPOS (*it) >= ZV_BYTE && FETCH_BYTE (ZV_BYTE - 1) != '\n'; 24121 IT_BYTEPOS (*it) >= ZV_BYTE
24122 && (ZV_BYTE <= 1 || FETCH_BYTE (ZV_BYTE - 1) != '\n');
24122 else 24123 else
24123 row->ends_at_zv_p = false; 24124 row->ends_at_zv_p = false;
24124 break; 24125 break;