From 0bb8582135d7c59abe539df92d0e95ee5178322c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Apr 2009 18:12:03 +0200 Subject: [PATCH] list_window: check range selection Check if the numbers in selected_start and selected_end are correct in the function list_window_check_selected(). --- src/list_window.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/list_window.c b/src/list_window.c index e14d6cf..7bdee1a 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -87,6 +87,19 @@ list_window_check_selected(struct list_window *lw, unsigned length) if(lw->range_selection) { + if (length == 0) { + lw->selected_start = 0; + lw->selected_end = 0; + lw->range_base = 0; + } else { + if (lw->selected_start >= length) + lw->selected_start = length - 1; + if (lw->selected_end >= length) + lw->selected_end = length - 1; + if (lw->range_base >= length) + lw->range_base = length - 1; + } + if(lw->range_base > lw->selected_end) lw->selected_end = lw->selected; if(lw->range_base < lw->selected_start) -- 2.30.2