]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: servers: Use a refcount for port_range and free it properly
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 1 Jul 2026 11:55:48 +0000 (13:55 +0200)
committerOlivier Houchard <cognet@ci0.org>
Wed, 1 Jul 2026 12:29:57 +0000 (14:29 +0200)
commitf59da779ca7d28c842898a3ecbc907939613f049
tree1ab5a49ffb1abd7ee8e507c785a3cc0d483b2ec1
parentaf9bb8507dde45829f88e8878dcb204834a12094
BUG/MEDIUM: servers: Use a refcount for port_range and free it properly

port_range was never freed. That used not to be a problem, but now that
we can dynamically add and remove servers, it becomes one, as that leads
to a memory leak each time a server with a "source" directive is destroyed.
However, just adding a free() is not enough. We have to add a refcount,
because the server is not the only one with a reference to it. We may
also have one in fdinfo, so that we know which port to release when we
finally close the fd.
So add a refcount, and make sure to call port_range_release() when a
server is destroyed.

This should be backported up to 3.0.
include/haproxy/port_range-t.h
include/haproxy/port_range.h
src/server.c