From: Michael D. Lowis Date: Thu, 2 Feb 2017 17:38:48 +0000 (-0500) Subject: fixed view api to not segfault when a view has 0 rows X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a275f2aaaf690ba00e57d5be940ace2162c13a6d;p=projs%2Ftide.git fixed view api to not segfault when a view has 0 rows --- diff --git a/lib/view.c b/lib/view.c index 36511ae..e01c036 100644 --- a/lib/view.c +++ b/lib/view.c @@ -71,6 +71,7 @@ static size_t fill_row(View* view, unsigned row, size_t pos) { } static void reflow(View* view) { + if (!view->nrows) return; size_t pos = view->rows[0]->off; for (size_t y = 0; y < view->nrows; y++) pos = fill_row(view, y, pos); @@ -140,6 +141,7 @@ static void sync_center(View* view, size_t csr) { } static void sync_view(View* view, size_t csr) { + if (!view->nrows) return; unsigned first = view->rows[0]->off; unsigned last = view->rows[view->nrows-1]->off + view->rows[view->nrows-1]->rlen - 1; while (csr < first)