From a0a28de5e393e5768343fbc17358aee40814dae6 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 2 Apr 2018 15:20:15 -0400 Subject: [PATCH] fixed issue with getb handling out of bounds offsets --- lib/buf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/buf.c b/lib/buf.c index 2b0e2e7..4adfc0e 100644 --- a/lib/buf.c +++ b/lib/buf.c @@ -141,6 +141,7 @@ static void putb(Buf* buf, char b, Sel* p_sel) { } static char getb(Buf* buf, size_t off) { + if (off >= buf_end(buf)) return '\n'; // TODO: get rid of this hack size_t bsz = (buf->gapstart - buf->bufstart); if (off < bsz) return *(buf->bufstart + off); -- 2.54.0