add missing NULLification of serout.delay_table after luaM_freearray() (#2220)

This commit is contained in:
Arnim Läuger 2018-01-10 21:25:35 +01:00 committed by Marcel Stör
parent ceadd30bca
commit fc2f325029
1 changed files with 5 additions and 2 deletions

View File

@ -228,8 +228,10 @@ static const os_param_t TIMER_OWNER = 0x6770696f; // "gpio"
static void seroutasync_done (task_param_t arg) static void seroutasync_done (task_param_t arg)
{ {
lua_State *L = lua_getstate(); lua_State *L = lua_getstate();
luaM_freearray(L, serout.delay_table, serout.tablelen, uint32); if (serout.delay_table) {
serout.delay_table = NULL; luaM_freearray(L, serout.delay_table, serout.tablelen, uint32);
serout.delay_table = NULL;
}
if (serout.lua_done_ref != LUA_NOREF) { if (serout.lua_done_ref != LUA_NOREF) {
lua_rawgeti (L, LUA_REGISTRYINDEX, serout.lua_done_ref); lua_rawgeti (L, LUA_REGISTRYINDEX, serout.lua_done_ref);
luaL_unref (L, LUA_REGISTRYINDEX, serout.lua_done_ref); luaL_unref (L, LUA_REGISTRYINDEX, serout.lua_done_ref);
@ -310,6 +312,7 @@ static int lgpio_serout( lua_State* L )
} }
} while (serout.repeats--); } while (serout.repeats--);
luaM_freearray(L, serout.delay_table, serout.tablelen, uint32); luaM_freearray(L, serout.delay_table, serout.tablelen, uint32);
serout.delay_table = NULL;
} }
return 0; return 0;
} }