dataroaring commented on code in PR #9727: URL: https://github.com/apache/incubator-doris/pull/9727#discussion_r884074140
########## be/src/util/faststring.cc: ########## @@ -37,18 +37,20 @@ void faststring::GrowToAtLeast(size_t newcapacity) { void faststring::GrowArray(size_t newcapacity) { DCHECK_GE(newcapacity, capacity_); - std::unique_ptr<uint8_t[]> newdata(new uint8_t[newcapacity]); - if (len_ > 0) { - memcpy(&newdata[0], &data_[0], len_); - } - capacity_ = newcapacity; + uint8_t* newdata = NULL; if (data_ != initial_data_) { - delete[] data_; + newdata = (uint8_t*)realloc((void*)data_, newcapacity); } else { + newdata = (uint8_t*)malloc(newcapacity); + if (len_ > 0) { + memcpy(newdata, data_, len_); + } + } + capacity_ = newcapacity; + data_ = newdata; + if (data_ == initial_data_) { ASAN_POISON_MEMORY_REGION(initial_data_, arraysize(initial_data_)); Review Comment: yep, there is a bug visible to the naked eye. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org