From 6dada97564cd1e9307a09969ccb0eb588fdf9b1a Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Tue, 4 Feb 2014 15:00:57 +0100 Subject: [PATCH] CLuaInstance::MenuAddItem: Fix neutrino segfault at (type == "chooser") when options in lua script broken --- src/gui/luainstance.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index af5a166af..96a9f0aa1 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -934,6 +934,10 @@ int CLuaInstance::MenuAddItem(lua_State *L) options_count++; } lua_pop(L, 1); + if (options_count == 0) { + m->m->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, "ERROR! (options_count)", NONEXISTANT_LOCALE)); + return 0; + } CMenuOptionChooser::keyval_ext *kext = (CMenuOptionChooser::keyval_ext *)calloc(options_count, sizeof(CMenuOptionChooser::keyval_ext)); m->tofree.push_back(kext);