Don't allocate an array of size 0, it causes a UBSan failure

Bug: webrtc:9587
Change-Id: I56bdf3c5c8744044b2d0d1fa3531fca504ea200f
Reviewed-on: https://webrtc-review.googlesource.com/92091
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24178}
This commit is contained in:
Oleh Prypin
2018-08-03 00:03:17 +02:00
committed by Commit Bot
parent 54bd8f54e9
commit 7d984ee1d7

View File

@ -87,7 +87,7 @@ class BufferT {
BufferT(size_t size, size_t capacity)
: size_(size),
capacity_(std::max(size, capacity)),
data_(new T[capacity_]) {
data_(capacity_ > 0 ? new T[capacity_] : nullptr) {
RTC_DCHECK(IsConsistent());
}