CLuaInstance::MenuAddItem: Fix neutrino segfault at (type == "chooser")

when options in lua script broken
This commit is contained in:
M. Liebmann
2014-02-04 15:00:57 +01:00
parent 1766553c56
commit 6dada97564

View File

@@ -934,6 +934,10 @@ int CLuaInstance::MenuAddItem(lua_State *L)
options_count++; options_count++;
} }
lua_pop(L, 1); 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)); CMenuOptionChooser::keyval_ext *kext = (CMenuOptionChooser::keyval_ext *)calloc(options_count, sizeof(CMenuOptionChooser::keyval_ext));
m->tofree.push_back(kext); m->tofree.push_back(kext);