From ac2912f2d236204ab82613f29bc17579bf57bf66 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 1 Aug 2011 11:52:01 +0200 Subject: [PATCH] Ensure menu ID is valid for active_menu --- src/luaconsole.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/luaconsole.c b/src/luaconsole.c index 8dce66547..6e4df7c68 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -855,12 +855,12 @@ int luatpt_airheat(lua_State* l) } int luatpt_active_menu(lua_State* l) { - int aheatstate; - aheatstate = luaL_optint(l, 1, menu_count); - if (aheatstate < SC_TOTAL) - active_menu = aheatstate; + int menuid; + menuid = luaL_optint(l, 1, 0); + if (menuid < SC_TOTAL && menuid > 0) + active_menu = menuid; else - return luaL_error(l, "Menu does not exist"); + return luaL_error(l, "Invalid menu"); return 0; } int luatpt_decorations_enable(lua_State* l)