aboutsummaryrefslogtreecommitdiff
path: root/src/navigator.c
diff options
context:
space:
mode:
authorDmitrij D. Czarkoff <czarkoff@gmail.com>2016-04-26 20:27:16 +0200
committerDmitrij D. Czarkoff <czarkoff@gmail.com>2016-04-26 20:30:58 +0200
commit4d2f36a98be483e021845e4e8fc17722a8aa800c (patch)
tree1da0a602202bca0bca3d3442e522a55c1003b265 /src/navigator.c
parent42fe047e7343b42369244d1d6e73f884af777c01 (diff)
downloadimv-4d2f36a98be483e021845e4e8fc17722a8aa800c.tar.gz
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
Diffstat (limited to 'src/navigator.c')
-rw-r--r--src/navigator.c4
1 files changed, 4 insertions, 0 deletions
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;