From d198bf547a2f29fbee54bb4fd18fa030c973a0cc Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 17 May 2016 23:23:54 -0400 Subject: [PATCH] Unit list search: reset cursor position to 0 before switching pages On empty lists, pressing "up" sets the cursor position to -1. This results in a crash if the list is populated, which the search plugin does before switching pages. Fixes #928 --- plugins/search.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/search.cpp b/plugins/search.cpp index a177665ad..80dcc0f61 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -1160,6 +1160,9 @@ private: if (!in_entry_mode()) { // Changing screens, reset search + int32_t *cursor_pos = get_viewscreen_cursor(); + if (cursor_pos && *cursor_pos < 0) + *cursor_pos = 0; clear_search(); reset_all(); }