diff --git a/flang/runtime/buffer.h b/flang/runtime/buffer.h --- a/flang/runtime/buffer.h +++ b/flang/runtime/buffer.h @@ -135,7 +135,7 @@ if (bytes > size_) { char *old{buffer_}; auto oldSize{size_}; - size_ = std::max(bytes, minBuffer); + size_ = std::max(bytes, size_ + minBuffer); buffer_ = reinterpret_cast(AllocateMemoryOrCrash(terminator, size_)); auto chunk{std::min(length_, oldSize - start_)};