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 a3f9abcbd1
commit fe7cda57e4
1 changed files with 3 additions and 2 deletions

View File

@ -122,7 +122,8 @@ PeakBuffer::Append(const void *data, size_t length)
return true; return true;
} }
if (peak_buffer == nullptr && peak_size > 0) { if (peak_buffer == nullptr) {
if (peak_size > 0)
peak_buffer = new DynamicFifoBuffer<uint8_t>(peak_size); peak_buffer = new DynamicFifoBuffer<uint8_t>(peak_size);
if (peak_buffer == nullptr) if (peak_buffer == nullptr)
return false; return false;