]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: Don't crash in hlua_lua2arg_check on failure
authorOlivier Houchard <cognet@ci0.org>
Mon, 12 Sep 2022 22:31:17 +0000 (00:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Oct 2022 17:08:10 +0000 (19:08 +0200)
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.

src/hlua.c

index aff2099cf52ccfe425b3ffa62818b304e7037075..cc2e6a6e2395bab7472c7ecada003a20bc925bf4 100644 (file)
@@ -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 */