]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed issue with getb handling out of bounds offsets
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 2 Apr 2018 19:20:15 +0000 (15:20 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 2 Apr 2018 19:20:15 +0000 (15:20 -0400)
lib/buf.c

index 2b0e2e711e9f0933e72769ca537c85de06ba8a2e..4adfc0e1f57b91937f751fa3a2a4fa0bcb4891fb 100644 (file)
--- 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);