Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent crash from -1 array idx when searching zones
Prevents the crash listed below that previously happened when searching for zones to add, but the search yielded no results: ``` Thread 1 "cataclysm-tiles" received signal SIGABRT, Aborted. __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007ffff7ad501e in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x0000555555de2639 in std::vector<uilist_entry, std::allocator<uilist_entry> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14/bits/stl_vector.h:1130 #6 std::vector<uilist_entry, std::allocator<uilist_entry> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14/bits/stl_vector.h:1128 #7 0x000055555699deac in uilist_impl::draw_controls (this=0x555599a181d0) at src/ui.cpp:138 #8 0x0000555555b7c312 in cataimgui::window::draw (this=0x555599a181d0) at src/cata_imgui.cpp:631 #9 cataimgui::window::draw (this=0x555599a181d0) at src/cata_imgui.cpp:600 #10 0x00005555569a2b1c in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440 #11 0x00005555569a2bd9 in ui_adaptor::redraw () at src/ui_manager.cpp:345 #12 0x00005555569a2c00 in ui_manager::redraw () at src/ui_manager.cpp:508 #13 0x000055555699bfa4 in uilist::inputfilter (this=this@entry=0x7fffffffb9c8) at src/ui.cpp:531 #14 0x000055555699ead4 in uilist::query (this=this@entry=0x7fffffffb9c8, loop=loop@entry=true, timeout=timeout@entry=-1, allow_unfiltered_hotkeys=allow_unfiltered_hotkeys@entry=false) at src/ui.cpp:865 #15 0x0000555555c610d4 in zone_manager::query_type (this=this@entry=0x555557274060 <zone_manager::get_manager()::manager>, personal=personal@entry=false) at src/clzones.cpp:621 #16 0x0000555555ef3894 in game::zones_manager (this=this@entry=0x555558291db0) at src/game.cpp:6944 #17 0x0000555555f5d279 in game::do_regular_action (this=this@entry=0x555558291db0, act=@0x7fffffffcfec: ACTION_ZONES, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2438 #18 0x0000555555f60769 in game::handle_action (this=0x555558291db0) at src/handle_action.cpp:3172 CleverRaven#19 0x0000555555dcf14d in do_turn () at src/do_turn.cpp:579 CleverRaven#20 0x00005555557a1217 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 ``` gdb shows that `parent.selected` was negative: ``` (gdb) frame 7 138 parent.entries[parent.selected].desc.c_str() (gdb) print parent.selected $1 = -1 (gdb) print parent.entries.size() $2 = 63 ```
- Loading branch information