From 4d2f36a98be483e021845e4e8fc17722a8aa800c Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Tue, 26 Apr 2016 20:27:16 +0200 Subject: Fix segmentation violation When non-cycling mode prevents navigator from wrapping to the other end of list, undo change to nav->cur_path. Otherwise it will remain out-of-bounds, so that subsequent calls to navigator functions may produce unexpected results, up to segmentation violation. Fixes #93 --- src/navigator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/navigator.c') diff --git a/src/navigator.c b/src/navigator.c index a64fb44..b4e65fb 100644 --- a/src/navigator.c +++ b/src/navigator.c @@ -146,12 +146,16 @@ int imv_navigator_select_rel(struct imv_navigator *nav, int direction, if(nav->cur_path == nav->num_paths) { /* end of list reached */ if(!cycle) { + /* undo move */ + nav->cur_path -= direction; return 0; } nav->cur_path = 0; } else if(nav->cur_path < 0) { /* going backwards at the beginning of the list */ if(!cycle) { + /* undo move */ + nav->cur_path -= direction; return 0; } nav->cur_path = nav->num_paths - 1; -- cgit v1.2.3