From: Aurelien DARRAGON Date: Thu, 9 Feb 2023 14:26:25 +0000 (+0100) Subject: BUG/MINOR: lua/httpclient: missing free in hlua_httpclient_send() X-Git-Tag: v2.8-dev5~139 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=035640733251b7b8ce0df80f5d7429c3cb19d8f9;p=thirdparty%2Fhaproxy.git BUG/MINOR: lua/httpclient: missing free in hlua_httpclient_send() In hlua_httpclient_send(), we replace hc->req.url with a new url. But we forgot to free the original url that was allocated in hlua_httpclient_new() or in the previous httpclient_send() call. Because of this, each httpclient request performed under lua scripts would result in a small leak. When stress-testing a lua action which uses httpclient, the leak is clearly visible since we're leaking severals Mbytes per minute. This bug was discovered by chance when trying to reproduce GH issue #2037. It must be backported up to 2.5 --- diff --git a/src/hlua.c b/src/hlua.c index 3467226753..184c1e7808 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -7409,6 +7409,7 @@ __LJMP static int hlua_httpclient_send(lua_State *L, enum http_meth_t meth) hlua_hc->sent = 0; + istfree(&hlua_hc->hc->req.url); hlua_hc->hc->req.url = istdup(ist(url_str)); hlua_hc->hc->req.meth = meth;