From a39653656755cc0d01165043922d6f38b2db2cf9 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 29 May 2007 13:08:21 +0200 Subject: [PATCH] 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. --- tig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- 2.30.2