Index: webrtc/base/copyonwritebuffer.h |
diff --git a/webrtc/base/copyonwritebuffer.h b/webrtc/base/copyonwritebuffer.h |
index 72fb4eea53495a2575ee435efade9d182afd4a69..108aaa19d7aae6aed91cda23bfe3f00a21183d0f 100644 |
--- a/webrtc/base/copyonwritebuffer.h |
+++ b/webrtc/base/copyonwritebuffer.h |
@@ -222,7 +222,13 @@ class CopyOnWriteBuffer { |
return; |
} |
- CloneDataIfReferenced(std::max(buffer_->capacity(), size)); |
+ // Clone data if referenced. |
+ if (!buffer_->HasOneRef()) { |
+ buffer_ = new RefCountedObject<Buffer>( |
+ buffer_->data(), |
+ std::min(buffer_->size(), size), |
+ std::max(buffer_->capacity(), size)); |
+ } |
buffer_->SetSize(size); |
RTC_DCHECK(IsConsistent()); |
} |