mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 06:41:32 +02:00
The input buffer passed as argument to create a new stream must not be transferred when the request channel is initialized because the channel flags are not set at this stage. In addition, the API is a bit confusing regarding the buffer owner when an error occurred. The caller remains the owner, but reading the code it is not obvious. So, first of all, to avoid any ambiguities, comments are added on the calling chain to make it clear. The buffer owner is the caller if any error occurred. And the ownership is transferred to the stream on success. Then, to make things simple, the ownership is transferred at the end of stream_new(), in case of success. And the input buffer is updated to point on BUF_NULL. Thus, in all cases, if the caller try to release it calling b_free() on it, it is not a problem. Of course, it remains the caller responsibility to release it on error. The patch fixes a bug introduced by the commit 26256f86e ("MINOR: stream: Pass an optional input buffer when a stream is created"). No backport is needed.