]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffers: Swap buffers of same size only
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 28 Jan 2026 14:02:20 +0000 (15:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 18 Feb 2026 12:26:20 +0000 (13:26 +0100)
In b_xfer(), we now take care to swap buffers of the same size only. For
now, it is always the case. But that will change.

src/buf.c

index afe33110b1028d7c98ba761d67b91f2fc3980ffd..19f38e504d1b02656b25e1abd0d23f49999d20ce 100644 (file)
--- a/src/buf.c
+++ b/src/buf.c
@@ -348,7 +348,7 @@ size_t b_xfer(struct buffer *dst, struct buffer *src, size_t count)
 
        if (ret > count)
                ret = count;
-       else if (!b_data(dst)) {
+       else if (!b_data(dst) && b_size(dst) == b_size(src)) {
                /* zero copy is possible by just swapping buffers */
                struct buffer tmp = *dst;
                *dst = *src;