Skip to content

Commit 8b8fb77

Browse files
Darleleta-denoyelle
authored andcommitted
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 30fcca1 ("MINOR: ssl/lua: CertCache.set() allows to update an SSL certificate file") (cherry picked from commit 755c2da) Signed-off-by: Amaury Denoyelle <[email protected]>
1 parent 342d239 commit 8b8fb77

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/hlua.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13143,8 +13143,9 @@ __LJMP static int hlua_ckch_commit_yield(lua_State *L, int status, lua_KContext
1314313143
error:
1314413144
ckch_store_free(new_ckchs);
1314513145
HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
13146-
WILL_LJMP(luaL_error(L, "%s", err));
13146+
hlua_pushfstring_safe(L, "%s", err);
1314713147
free(err);
13148+
WILL_LJMP(lua_error(L));
1314813149

1314913150
return 0;
1315013151
}
@@ -13287,7 +13288,9 @@ __LJMP static int hlua_ckch_set(lua_State *L)
1328713288

1328813289
if (errcode & ERR_CODE) {
1328913290
ckch_store_free(new_ckchs);
13290-
WILL_LJMP(luaL_error(L, "%s", err));
13291+
hlua_pushfstring_safe(L, "%s", err);
13292+
free(err);
13293+
WILL_LJMP(lua_error(L));
1329113294
}
1329213295
free(err);
1329313296

0 commit comments

Comments
 (0)