From: Michael D. Lowis Date: Mon, 2 Apr 2018 19:20:15 +0000 (-0400) Subject: fixed issue with getb handling out of bounds offsets X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a0a28de5e393e5768343fbc17358aee40814dae6;p=projs%2Ftide.git fixed issue with getb handling out of bounds offsets --- 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);