mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
BUG/MINOR: hlua: fix leak in hlua_ckch_set() error path
in hlua_ckch_commit_yield() and hlua_ckch_set(), when an error occurs,
we enter the error path and try to raise an error from the <err> msg
pointer which must be freed afterwards.
However, the fact that luaL_error() never returns was overlooked, because
of that <err> msg is never freed in such case.
To fix the issue, let's use hlua_pushfstring_safe() helper to push the
err on the lua stack and then free it before throwing the error using
lua_error().
It should be backported up to 2.6 with 30fcca18
("MINOR: ssl/lua:
CertCache.set() allows to update an SSL certificate file")
This commit is contained in:
parent
2be94c008e
commit
755c2daf0f
@ -13135,8 +13135,9 @@ __LJMP static int hlua_ckch_commit_yield(lua_State *L, int status, lua_KContext
|
||||
error:
|
||||
ckch_store_free(new_ckchs);
|
||||
HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
|
||||
WILL_LJMP(luaL_error(L, "%s", err));
|
||||
hlua_pushfstring_safe(L, "%s", err);
|
||||
free(err);
|
||||
WILL_LJMP(lua_error(L));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -13279,7 +13280,9 @@ __LJMP static int hlua_ckch_set(lua_State *L)
|
||||
|
||||
if (errcode & ERR_CODE) {
|
||||
ckch_store_free(new_ckchs);
|
||||
WILL_LJMP(luaL_error(L, "%s", err));
|
||||
hlua_pushfstring_safe(L, "%s", err);
|
||||
free(err);
|
||||
WILL_LJMP(lua_error(L));
|
||||
}
|
||||
free(err);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user