Code

list_window: check range selection
authorMax Kellermann <max@duempel.org>
Wed, 15 Apr 2009 16:12:03 +0000 (18:12 +0200)
committerMax Kellermann <max@duempel.org>
Wed, 15 Apr 2009 16:12:03 +0000 (18:12 +0200)
Check if the numbers in selected_start and selected_end are correct in
the function list_window_check_selected().

src/list_window.c

index e14d6cfad4acb26c9ecdb869586c3f9f8c410442..7bdee1a4e67bc4fc46b2dbab8c22dac4c586f29b 100644 (file)
@@ -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)