]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sink: do not free existing sinks on allocation error
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 05:58:23 +0000 (07:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Apr 2026 06:01:24 +0000 (08:01 +0200)
commit76d894956f7c83bd503afc65a8c8240a6c527f40
treeaa8d10bc7caffe68646c712bad5af8a64c6140af
parent19e17fd6e25bff66c93b90ceacc1fd6d41984eb4
BUG/MINOR: sink: do not free existing sinks on allocation error

In 3.1 with commit 1bdf6e884a ("MEDIUM: sink: implement sink_find_early()")
sink creation started to support plugging to an existing sink and only
updating the description. However if the strdup() for the new description
failed, it would go down the error path releasing everything, while leaving
the released entry in the sink list and leaving other users still attached
to it.

Here we take a different approach, we first allocate the new description,
and release the old one on success, otherwise we leave the entry unchanged.
And we only release new sinks, not old ones. This way allocation errors
just do not change what is already referenced elsewhere, so that error
unrolling remains clean.

This remains of low importance anyway since it's only a case of boot
error aggravation. Not really needed to be backported.
src/sink.c