Invalid memory access in the pause menu
Created by: christopho
Valgrind reports the following error the first time you change the pause submenu in zsdx:
==16771== Invalid read of size 8
==16771== at 0x59381D: std::_List_iterator<LuaContext::LuaMenuData>::operator--() (stl_list.h:169)
==16771== by 0x5937C8: std::reverse_iterator<std::_List_iterator<LuaContext::LuaMenuData> >::operator++() (stl_iterator.h:179)
==16771== by 0x5932B2: LuaContext::menus_on_command_pressed(int, GameCommands::Command) (MenuAPI.cpp:371)
==16771== by 0x5357D9: LuaContext::game_on_command_pressed(Game&, GameCommands::Command) (GameAPI.cpp:1228)
==16771== by 0x4A36F5: Game::notify_command_pressed(GameCommands::Command) (Game.cpp:252)
==16771== by 0x4B3E90: GameCommands::game_command_pressed(GameCommands::Command) (GameCommands.cpp:511)
==16771== by 0x4B1E9F: GameCommands::keyboard_key_pressed(InputEvent::KeyboardKey) (GameCommands.cpp:204)
==16771== by 0x4B1CD1: GameCommands::notify_input(InputEvent&) (GameCommands.cpp:170)
==16771== by 0x4A365C: Game::notify_input(InputEvent&) (Game.cpp:228)
==16771== by 0x4A0E13: MainLoop::notify_input(InputEvent&) (MainLoop.cpp:259)
==16771== by 0x4A0B32: MainLoop::run() (MainLoop.cpp:169)
==16771== by 0x4A0185: main (Main.cc:63)
==16771== Address 0xe798f18 is 8 bytes inside a block of size 32 free'd
==16771== at 0x4C2A4BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==16771== by 0x52680F: __gnu_cxx::new_allocator<std::_List_node<LuaContext::LuaMenuData> >::deallocate(std::_List_node<LuaContext::LuaMenuData>*, unsigned long) (new_allocator.h:98)
==16771== by 0x5267E1: std::_List_base<LuaContext::LuaMenuData, std::allocator<LuaContext::LuaMenuData> >::_M_put_node(std::_List_node<LuaContext::LuaMenuData>*) (stl_list.h:331)
==16771== by 0x593A0C: std::list<LuaContext::LuaMenuData, std::allocator<LuaContext::LuaMenuData> >::_M_erase(std::_List_iterator<LuaContext::LuaMenuData>) (stl_list.h:1539)
==16771== by 0x5935CF: std::list<LuaContext::LuaMenuData, std::allocator<LuaContext::LuaMenuData> >::erase(std::_List_iterator<LuaContext::LuaMenuData>) (list.tcc:113)
==16771== by 0x592627: LuaContext::menu_api_stop(lua_State*) (MenuAPI.cpp:146)
==16771== by 0x574A23B: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x5754D87: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x574A64C: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x57498D6: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x574A801: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x5746360: lua_pcall (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x51C52E: LuaContext::call_function(lua_State*, int, int, std::string const&) (LuaContext.cpp:847)
==16771== by 0x51993B: LuaContext::call_function(int, int, std::string const&) (LuaContext.cpp:824)
==16771== by 0x51D8A8: LuaContext::on_started() (LuaContext.cpp:1466)
==16771== by 0x5928AD: LuaContext::menu_on_started(int) (MenuAPI.cpp:184)
==16771== by 0x59286F: LuaContext::add_menu(int, int) (MenuAPI.cpp:58)
==16771== by 0x592531: LuaContext::menu_api_start(lua_State*) (MenuAPI.cpp:121)
==16771== by 0x574A23B: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x5754D87: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x574A64C: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x57498D6: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x574A801: ??? (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x5746360: lua_pcall (in /usr/lib/x86_64-linux-gnu/liblua5.1.so.0.0.0)
==16771== by 0x51C52E: LuaContext::call_function(lua_State*, int, int, std::string const&) (LuaContext.cpp:847)
==16771== by 0x51993B: LuaContext::call_function(int, int, std::string const&) (LuaContext.cpp:824)
==16771== by 0x51F85F: LuaContext::on_command_pressed(GameCommands::Command) (LuaContext.cpp:1824)
==16771== by 0x592DA3: LuaContext::menu_on_command_pressed(int, GameCommands::Command) (MenuAPI.cpp:252)
==16771== by 0x5932A4: LuaContext::menus_on_command_pressed(int, GameCommands::Command) (MenuAPI.cpp:374)
==16771== by 0x5357D9: LuaContext::game_on_command_pressed(Game&, GameCommands::Command) (GameAPI.cpp:1228)
==16771== by 0x4A36F5: Game::notify_command_pressed(GameCommands::Command) (Game.cpp:252)
==16771== by 0x4B3E90: GameCommands::game_command_pressed(GameCommands::Command) (GameCommands.cpp:511)
==16771== by 0x4B1E9F: GameCommands::keyboard_key_pressed(InputEvent::KeyboardKey) (GameCommands.cpp:204)
==16771== by 0x4B1CD1: GameCommands::notify_input(InputEvent&) (GameCommands.cpp:170)
==16771== by 0x4A365C: Game::notify_input(InputEvent&) (Game.cpp:228)
==16771== by 0x4A0E13: MainLoop::notify_input(InputEvent&) (MainLoop.cpp:259)
==16771== by 0x4A0B32: MainLoop::run() (MainLoop.cpp:169)
==16771== by 0x4A0185: main (Main.cc:63)