From 53f55f8e1dc8fafd8a18fd026f4d147a125f5817 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 15 Feb 2017 21:25:08 +0100 Subject: [PATCH] Fixes #4399: problem getting/setting curve on output with Lua (#4455) --- radio/src/lua/api_model.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/radio/src/lua/api_model.cpp b/radio/src/lua/api_model.cpp index 482d669cf..11f32fbf1 100644 --- a/radio/src/lua/api_model.cpp +++ b/radio/src/lua/api_model.cpp @@ -984,8 +984,6 @@ static int luaModelGetOutput(lua_State *L) lua_pushtableinteger(L, "revert", limit->revert); if (limit->curve) lua_pushtableinteger(L, "curve", limit->curve-1); - else - lua_pushtablenil(L, "curve"); } else { lua_pushnil(L); @@ -1012,6 +1010,7 @@ static int luaModelSetOutput(lua_State *L) unsigned int idx = luaL_checkunsigned(L, 1); if (idx < MAX_OUTPUT_CHANNELS) { LimitData * limit = limitAddress(idx); + memclear(limit, sizeof(LimitData)); luaL_checktype(L, -1, LUA_TTABLE); for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { luaL_checktype(L, -2, LUA_TSTRING); // key is string @@ -1039,10 +1038,7 @@ static int luaModelSetOutput(lua_State *L) limit->revert = luaL_checkinteger(L, -1); } else if (!strcmp(key, "curve")) { - if (lua_isnil(L, -1)) - limit->curve = 0; - else - limit->curve = luaL_checkinteger(L, -1) + 1; + limit->curve = luaL_checkinteger(L, -1) + 1; } } storageDirty(EE_MODEL);