util/PeakBuffer: fix nullptr dereference when peak_size==0

This commit is contained in:
Max Kellermann 2014-01-14 23:07:04 +01:00
parent a1b798e555
commit 56f082c9d4

View File

@ -130,8 +130,9 @@ PeakBuffer::Append(const void *data, size_t length)
return true;
}
if (peak_buffer == nullptr && peak_size > 0) {
peak_buffer = (fifo_buffer *)HugeAllocate(peak_size);
if (peak_buffer == nullptr) {
if (peak_size > 0)
peak_buffer = (fifo_buffer *)HugeAllocate(peak_size);
if (peak_buffer == nullptr)
return false;