From: Jonas Fonseca Date: Tue, 29 May 2007 11:08:21 +0000 (+0200) Subject: move_view: fix view->offset overflow bug X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a39653656755cc0d01165043922d6f38b2db2cf9;p=tig.git move_view: fix view->offset overflow bug Reproducable by opening the tree view, then maximizing the blob view, move up, and then closing the blob view, causing the view->offset to have "wrapped around" and nothing to be displayed in the tree view. The invalid update of view->offset only happend when moving non-displayed views. Instead use the checked scroll_steps variable instead of the steps variable. Add a guarding assert after the update. --- diff --git a/tig.c b/tig.c index 00888dd..7cf25ca 100644 --- a/tig.c +++ b/tig.c @@ -1622,7 +1622,8 @@ move_view(struct view *view, enum request request) } if (!view_is_displayed(view)) { - view->offset += steps; + view->offset += scroll_steps; + assert(0 <= view->offset && view->offset < view->lines); view->ops->select(view, &view->line[view->lineno]); return; }