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);