summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lua
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-11-16 20:54:30 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2022-11-16 20:54:30 -0500
commit4c3937591c510a22c724d18dae9367bb1b786698 (patch)
treea0193c33a9e4660986c9e126ca8229506825c191 /apps/plugins/lua
parent2f278af7606039857bb92d659c811403f27ad463 (diff)
downloadrockbox-4c3937591c510a22c724d18dae9367bb1b786698.tar.gz
rockbox-4c3937591c510a22c724d18dae9367bb1b786698.zip
lua Fix potential event stack OVFL
you could return values in the event callbacks that would never be processed this would eventually cause a lua stack overflow settop(0) eats all return values (if any) Change-Id: Icac6b27e592b385421275d4bd899ed3fe1065669
Diffstat (limited to 'apps/plugins/lua')
-rw-r--r--apps/plugins/lua/rocklib_events.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/plugins/lua/rocklib_events.c b/apps/plugins/lua/rocklib_events.c
index 1c13a6758f..0cdec20213 100644
--- a/apps/plugins/lua/rocklib_events.c
+++ b/apps/plugins/lua/rocklib_events.c
@@ -253,7 +253,9 @@ static int lua_rev_callback(lua_State *L, struct cb_data *evt)
lua_pushlightuserdata(L, evt->data);
lua_status = lua_resume(L, 2); /* call the saved function */
- if (lua_status == LUA_YIELD) /* coroutine.yield() disallowed */
+ if (lua_status == LUA_SUCCESS)
+ lua_settop(L, 0); /* eat any value(s) returned */
+ else if (lua_status == LUA_YIELD) /* coroutine.yield() disallowed */
luaL_where(L, 1); /* push error string on stack */
return lua_status;