From a740608453525c7f7645df0740ee8267b43a779b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 9 Jul 2022 13:16:12 +0300 Subject: [PATCH] Fix segfault in composite.c * src/composite.c (find_automatic_composition): Don't use narrowed_begv if it's zero. This avoids segfault in BACKWARD_CHAR, since zero is not a valid buffer position. --- src/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/composite.c b/src/composite.c index d8998b5a1f3..4f7b4b0a2c7 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1590,7 +1590,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit, ptrdiff_t backlim, /* In buffers with very long lines, this function becomes very slow. Pretend that the buffer is narrowed to make it fast. */ narrowed_begv = get_narrowed_begv (w); - if (pos > narrowed_begv) + if (narrowed_begv && pos > narrowed_begv) head = narrowed_begv; cur.pos_byte = CHAR_TO_BYTE (cur.pos); cur.p = BYTE_POS_ADDR (cur.pos_byte); -- 2.39.2