From b38add8de55c7dd90e0f2a200f8c5a19a494d088 Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Thu, 8 Jul 2021 11:20:08 +0800 Subject: [PATCH] move arg checking code to the top --- src/api/process.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/process.c b/src/api/process.c index 5b26871f..168fcf9c 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -59,6 +59,13 @@ static int process_start(lua_State* L) { int cmd_len = lua_rawlen(L, 1) + 1; const char** cmd = malloc(sizeof(char *) * cmd_len); + luaL_checktype(L, 1, LUA_TTABLE); + if (lua_isnoneornil(L, 2)) { + lua_settop(L, 1); // remove the nil if it's there + lua_newtable(L); + } + luaL_checktype(L, 2, LUA_TTABLE); + ASSERT_MALLOC(cmd); cmd[cmd_len] = NULL;