diff options
author | Aurelien DARRAGON <adarragon@haproxy.com> | 2023-05-10 19:47:08 +0200 |
---|---|---|
committer | Christopher Faulet <cfaulet@haproxy.com> | 2023-05-11 09:23:14 +0200 |
commit | c0af7cdba26ab20f77c96e0cf5360141558a5744 (patch) | |
tree | 7e6f2fdee82b98aba6d2b22a86e09ad3ad5379cb | |
parent | bd8a94a7594c746b717fde686ea4e3fbdf41f4e9 (diff) | |
download | haproxy-c0af7cdba26ab20f77c96e0cf5360141558a5744.tar.gz |
BUG/MINOR: hlua_fcn/queue: fix reference leak
When pushing a lua object through lua Queue class, a new reference is
created from the object so that it can be safely restored when needed.
Likewise, when popping an object from lua Queue class, the object is
restored at the top of the stack via its reference id.
However, once the object is restored the related queue entry is removed,
thus the object reference must be dropped to prevent reference leak.
-rw-r--r-- | src/hlua_fcn.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 27396144e..3347211d0 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -600,6 +600,11 @@ static int _hlua_queue_pop(lua_State *L, struct hlua_queue *queue) /* push lua obj on the stack */ hlua_pushref(L, item->ref); + /* obj ref should be released right away since it was pushed + * on the stack and will not be used anymore + */ + hlua_unref(L, item->ref); + /* free the queue item */ pool_free(pool_head_hlua_queue, item); |