Skip to content

Commit fc2f325

Browse files
devsaurusmarcelstoer
authored andcommitted
add missing NULLification of serout.delay_table after luaM_freearray() (#2220)
1 parent ceadd30 commit fc2f325

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/modules/gpio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ static const os_param_t TIMER_OWNER = 0x6770696f; // "gpio"
228228
static void seroutasync_done (task_param_t arg)
229229
{
230230
lua_State *L = lua_getstate();
231-
luaM_freearray(L, serout.delay_table, serout.tablelen, uint32);
232-
serout.delay_table = NULL;
231+
if (serout.delay_table) {
232+
luaM_freearray(L, serout.delay_table, serout.tablelen, uint32);
233+
serout.delay_table = NULL;
234+
}
233235
if (serout.lua_done_ref != LUA_NOREF) {
234236
lua_rawgeti (L, LUA_REGISTRYINDEX, serout.lua_done_ref);
235237
luaL_unref (L, LUA_REGISTRYINDEX, serout.lua_done_ref);
@@ -310,6 +312,7 @@ static int lgpio_serout( lua_State* L )
310312
}
311313
} while (serout.repeats--);
312314
luaM_freearray(L, serout.delay_table, serout.tablelen, uint32);
315+
serout.delay_table = NULL;
313316
}
314317
return 0;
315318
}

0 commit comments

Comments
 (0)