]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed view api to not segfault when a view has 0 rows
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 2 Feb 2017 17:38:48 +0000 (12:38 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 2 Feb 2017 17:38:48 +0000 (12:38 -0500)
lib/view.c

index 36511ae45a3619973e66320467aaeb9f85a532bf..e01c036a334fa75fe47850132042e0ac47a34d99 100644 (file)
@@ -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)