From 2c6a654bcfcd3bb6995266a2b1e8b076da97d8ae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 1 Mar 2022 13:54:03 +0200 Subject: Fix bug in JSON serializer buffer growth logic --- libbutl/json/serializer.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libbutl/json/serializer.cxx b/libbutl/json/serializer.cxx index 6f9bc95..84941ed 100644 --- a/libbutl/json/serializer.cxx +++ b/libbutl/json/serializer.cxx @@ -363,7 +363,9 @@ namespace butl if (overflow_ == nullptr) return false; - overflow_ (data_, e, buf_, size + extra - cap); + extra += size; + extra -= cap; + overflow_ (data_, e, buf_, extra > min ? extra : min); cap = buf_.capacity - buf_.size; return cap >= min; -- cgit v1.1