handle errors from view_resize() in tog
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/tog/tog.c b/tog/tog.c
index adca206..cf32a40 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -890,7 +890,9 @@ show_log_view(struct got_object_id *start_id, struct got_repository *repo,
break;
}
case KEY_RESIZE:
- view_resize(view);
+ err = view_resize(view);
+ if (err)
+ goto done;
if (selected > view->nlines - 2)
selected = view->nlines - 2;
if (selected > commits.ncommits - 1)
@@ -1160,12 +1162,15 @@ show_diff_view(struct tog_view *view, struct got_object *obj1,
}
break;
case KEY_RESIZE:
- view_resize(view);
+ err = view_resize(view);
+ if (err)
+ goto done;
break;
default:
break;
}
}
+done:
fclose(f);
return err;
}
@@ -1869,7 +1874,9 @@ show_blame_view(const char *path, struct got_object_id *commit_id,
blame.nlines - (view->nlines - 3);
break;
case KEY_RESIZE:
- view_resize(view);
+ err = view_resize(view);
+ if (err)
+ break;
if (selected_line > view->nlines - 2) {
selected_line = MIN(blame.nlines,
view->nlines - 2);
@@ -2379,7 +2386,9 @@ show_tree_view(struct got_tree_object *root, struct got_object_id *commit_id,
}
break;
case KEY_RESIZE:
- view_resize(view);
+ err = view_resize(view);
+ if (err)
+ goto done;
if (selected > view->nlines)
selected = ndisplayed - 1;
break;