From fc2f3250293c6c3d8764cf093ad35bebfad57e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnim=20L=C3=A4uger?= Date: Wed, 10 Jan 2018 21:25:35 +0100 Subject: [PATCH] add missing NULLification of serout.delay_table after luaM_freearray() (#2220) --- app/modules/gpio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/modules/gpio.c b/app/modules/gpio.c index 86762543..1bf40fb0 100644 --- a/app/modules/gpio.c +++ b/app/modules/gpio.c @@ -228,8 +228,10 @@ static const os_param_t TIMER_OWNER = 0x6770696f; // "gpio" static void seroutasync_done (task_param_t arg) { lua_State *L = lua_getstate(); - luaM_freearray(L, serout.delay_table, serout.tablelen, uint32); - serout.delay_table = NULL; + if (serout.delay_table) { + luaM_freearray(L, serout.delay_table, serout.tablelen, uint32); + serout.delay_table = NULL; + } if (serout.lua_done_ref != LUA_NOREF) { lua_rawgeti (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--); luaM_freearray(L, serout.delay_table, serout.tablelen, uint32); + serout.delay_table = NULL; } return 0; }