vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit a3c632e3c78a0403697204cf1c880ba96c97151a
parent b5271a55afb504854af8fd96b0ab6870aa3d0a98
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 20 Oct 2020 15:32:16 +0200

text: avoid invalid pointer arithmetic

Diffstat:
Mtext.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/text.c b/text.c @@ -803,8 +803,8 @@ static bool iterator_init(Iterator *it, size_t pos, Piece *p, size_t off) { .pos = pos, .piece = p, .start = p ? p->data : NULL, - .end = p ? p->data + p->len : NULL, - .text = p ? p->data + off : NULL, + .end = p && p->data ? p->data + p->len : NULL, + .text = p && p->data ? p->data + off : NULL, }; *it = iter; return text_iterator_valid(it);