From: Olivier Houchard Date: Mon, 12 Sep 2022 22:31:17 +0000 (+0200) Subject: BUG/MEDIUM: lua: Don't crash in hlua_lua2arg_check on failure X-Git-Tag: v2.7-dev8~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca43161a8da278ec0948511f595827daf29a071e;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: lua: Don't crash in hlua_lua2arg_check on failure In hlua_lua2arg_check(), on failure, before calling free_argp(), make sure to always mark the failed argument as ARGT_STOP. We only want to free argument prior to that point, because we did not allocate the strings after this one, and so we don't want to free them. This should be backported up to 2.2. --- diff --git a/src/hlua.c b/src/hlua.c index aff2099cf5..cc2e6a6e23 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1101,6 +1101,7 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp, return 0; error: + argp[idx].type = ARGT_STOP; free_args(argp); WILL_LJMP(luaL_argerror(L, first + idx, msg)); return 0; /* Never reached */