From: Max Kellermann Date: Wed, 15 Apr 2009 16:12:03 +0000 (+0200) Subject: list_window: check range selection X-Git-Tag: release-0.14~16 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0bb8582135d7c59abe539df92d0e95ee5178322c;p=ncmpc.git list_window: check range selection Check if the numbers in selected_start and selected_end are correct in the function list_window_check_selected(). --- 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)