[squid-dev] [PREVIEW] Free AccessLogEntry::url when needed

Nathan Hoad nathan at getoffmalawn.com
Thu Mar 10 23:53:46 UTC 2016


Hello,

The attached patch is a demonstration of a memory leak on
AccessLogentry::url, created by ACLFilledChecklist::syncAle(). The
patch itself is not good enough quality to warrant acceptance, and no
doubt introduces bugs.

::syncAle() is the only place in the codebase that assigns a URL that
AccessLogEntry is expected to free(), which AccessLogEntry doesn't do.
This results in a memory leak.

As mentioned, the patch is of questionable quality, as the chunk in
src/client_side.cc shows. This sort of change would have to be made
everywhere that url is assigned to, which isn't practical.

It would be good to modify ::syncAle() so that it doesn't allocate a
new URL, but I'm not sure how that could be achieved. I think the only
workable alternative is to change AccessLogEntry::url to a more
intelligent string type. There is also the possibility of making the
member private and using a setter to ensure it is always xstrdup'd
from another URL.

If someone with better knowledge than me would like to make a
recommendation on what to do here, I'd be happy to work towards a
better solution.

Thank you,

Nathan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: incomplete-free-accesslogentry-url.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.squid-cache.org/pipermail/squid-dev/attachments/20160311/5acfa6eb/attachment.bin>


More information about the squid-dev mailing list