From bc8997dc932ffc2e375480cacd8ee1ad684b0785 Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Sat, 13 Jul 2024 22:27:57 +0200 Subject: [PATCH] Fix bug when we take bytes from an appendable data buffer. We took over o.free_ but this makes the current buffer appendable, which is wrong. --- src/utils/DataBuffer.hxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/DataBuffer.hxx b/src/utils/DataBuffer.hxx index b0b2e5ae5..1e2695bff 100644 --- a/src/utils/DataBuffer.hxx +++ b/src/utils/DataBuffer.hxx @@ -38,6 +38,8 @@ #include "utils/Buffer.hxx" #include "utils/LinkedObject.hxx" +#include "utils/macros.h" + #ifdef GTEST //#define DEBUG_DATA_BUFFER_FREE @@ -587,7 +589,11 @@ public: o.head_->unref(); } tail_ = o.tail_; - free_ = o.free_; + if (o.free_ < 0) { + free_ = o.free_; + } else { + free_ = -tail_->size(); + } size_ += o.size_; return true; }