diff --git a/runtime/platform/text_buffer.cc b/runtime/platform/text_buffer.cc index b1ef63ac679..ec42113fd1e 100644 --- a/runtime/platform/text_buffer.cc +++ b/runtime/platform/text_buffer.cc @@ -135,12 +135,7 @@ void TextBuffer::AddEscapedString(const char* s) { void TextBuffer::EnsureCapacity(intptr_t len) { intptr_t remaining = buf_size_ - msg_len_; if (remaining <= len) { - const int kBufferSpareCapacity = 64; // Somewhat arbitrary. - // TODO(turnidge): do we need to guard against overflow or other - // security issues here? Text buffers are used by the debugger - // to send user-controlled data (e.g. values of string variables) to - // the debugger front-end. - intptr_t new_size = buf_size_ + len + kBufferSpareCapacity; + intptr_t new_size = buf_size_ + Utils::Maximum(buf_size_, len); char* new_buf = reinterpret_cast(realloc(buf_, new_size)); if (new_buf == NULL) { OUT_OF_MEMORY(); diff --git a/runtime/vm/compilation_trace.cc b/runtime/vm/compilation_trace.cc index 29cdfa2077a..4c4db1e7222 100644 --- a/runtime/vm/compilation_trace.cc +++ b/runtime/vm/compilation_trace.cc @@ -20,7 +20,7 @@ namespace dart { DEFINE_FLAG(bool, trace_compilation_trace, false, "Trace compilation trace."); CompilationTraceSaver::CompilationTraceSaver(Zone* zone) - : buf_(zone, 4 * KB), + : buf_(zone, 1 * MB), func_name_(String::Handle(zone)), cls_(Class::Handle(zone)), cls_name_(String::Handle(zone)), diff --git a/runtime/vm/zone_text_buffer.cc b/runtime/vm/zone_text_buffer.cc index 5754b115509..8d3032bca9d 100644 --- a/runtime/vm/zone_text_buffer.cc +++ b/runtime/vm/zone_text_buffer.cc @@ -50,12 +50,7 @@ void ZoneTextBuffer::AddString(const char* s) { void ZoneTextBuffer::EnsureCapacity(intptr_t len) { intptr_t remaining = capacity_ - length_; if (remaining <= len) { - const int kBufferSpareCapacity = 64; // Somewhat arbitrary. - // TODO(turnidge): do we need to guard against overflow or other - // security issues here? Text buffers are used by the debugger - // to send user-controlled data (e.g. values of string variables) to - // the debugger front-end. - intptr_t new_capacity = capacity_ + len + kBufferSpareCapacity; + intptr_t new_capacity = capacity_ + Utils::Maximum(capacity_, len); buffer_ = zone_->Realloc(buffer_, capacity_, new_capacity); capacity_ = new_capacity; }