diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-08-19 22:31:37 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2018-08-24 10:34:02 +0000 |
commit | 4a466f50074adedfa9e98ad947a4ebfb876d8586 (patch) | |
tree | 2754687f2d6fea229c28f0ec1d7f5393002c03ce /src/host/layer23/src/mobile | |
parent | 9d6d9a6b3bac4885ad4828aec33d62fad9544795 (diff) |
Forget about the callback after use and cancellation
Don't try to unref something else after we have given up our
spot in the table.
Change-Id: I4e8db297e816d3d07a46147d5d3bdc0e8fae6c9a
Diffstat (limited to 'src/host/layer23/src/mobile')
-rw-r--r-- | src/host/layer23/src/mobile/script_lua.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/script_lua.c b/src/host/layer23/src/mobile/script_lua.c index 4cfe55a9..088aab33 100644 --- a/src/host/layer23/src/mobile/script_lua.c +++ b/src/host/layer23/src/mobile/script_lua.c @@ -136,6 +136,7 @@ static void handle_timeout(struct mobile_prim_intf *intf, struct mobile_timer_pa lua_rawgeti(L, LUA_REGISTRYINDEX, timer->cb_ref); luaL_unref(L, LUA_REGISTRYINDEX, timer->cb_ref); + timer->cb_ref = LUA_NOREF; err = lua_pcall(L, 0, 0, 0); if (err) { @@ -276,6 +277,10 @@ static int lua_timer_cancel(lua_State *L) luaL_argcheck(L, lua_isuserdata(L, -1), 1, "No userdata"); timer = lua_touserdata(L, -1); + if (timer->cb_ref != LUA_NOREF) { + luaL_unref(L, LUA_REGISTRYINDEX, timer->cb_ref); + timer->cb_ref = LUA_NOREF; + } prim = mobile_prim_alloc(PRIM_MOB_TIMER_CANCEL, PRIM_OP_REQUEST); prim->u.timer.timer_id = (intptr_t) timer; |