Unverified Commit 25625b95 authored by Feng Xiao's avatar Feng Xiao Committed by GitHub

Merge pull request #4590 from PetterS/undefined_fix

Fix error in Clang UndefinedBehaviorSanitizer
parents 513b35dc d14cacd7
......@@ -350,10 +350,12 @@ void Printer::CopyToBuffer(const char* data, int size) {
while (size > buffer_size_) {
// Data exceeds space in the buffer. Copy what we can and request a
// new buffer.
memcpy(buffer_, data, buffer_size_);
offset_ += buffer_size_;
data += buffer_size_;
size -= buffer_size_;
if (buffer_size_ > 0) {
memcpy(buffer_, data, buffer_size_);
offset_ += buffer_size_;
data += buffer_size_;
size -= buffer_size_;
}
void* void_buffer;
failed_ = !output_->Next(&void_buffer, &buffer_size_);
if (failed_) return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment