From c49ceac12149a700a8075f98640e0754b2099d7b Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Fri, 12 Sep 2014 19:43:59 +0200 Subject: [PATCH] luainstance: Fix default parameter for config file setXXX functions --- src/gui/luainstance.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 8ec6754ea..1f59cc8ca 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -2292,9 +2292,12 @@ int CLuaInstance::LuaConfigFileSetString(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; + int numargs = lua_gettop(L); const char *key = luaL_checkstring(L, 2); - const char *val = luaL_checkstring(L, 3); + const char *val = ""; + if (numargs > 2) + val = luaL_checkstring(L, 3); c->c->setString(key, val); return 0; } @@ -2316,9 +2319,12 @@ int CLuaInstance::LuaConfigFileSetInt32(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; + int numargs = lua_gettop(L); const char *key = luaL_checkstring(L, 2); - int val = luaL_checkint(L, 3); + int val = 0; + if (numargs > 2) + val = luaL_checkint(L, 3); c->c->setInt32(key, val); return 0; } @@ -2340,9 +2346,12 @@ int CLuaInstance::LuaConfigFileSetBool(lua_State *L) { CLuaConfigFile *c = LuaConfigFileCheck(L, 1); if (!c) return 0; + int numargs = lua_gettop(L); const char *key = luaL_checkstring(L, 2); - bool val = _luaL_checkbool(L, 3); + bool val = false; + if (numargs > 2) + val = _luaL_checkbool(L, 3); c->c->setBool(key, val); return 0; }