diff options
author | Max Kellermann <max@duempel.org> | 2014-01-14 23:07:04 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-14 23:07:04 +0100 |
commit | fe7cda57e46aa133cf84abc76308388bbf091cbb (patch) | |
tree | 9ba351959f8d2ca5906365bca68d5e361696c5e4 /src/util | |
parent | a3f9abcbd1d10c14cd8e1fa5abbd76cc12532949 (diff) | |
download | mpd-fe7cda57e46aa133cf84abc76308388bbf091cbb.tar.gz mpd-fe7cda57e46aa133cf84abc76308388bbf091cbb.tar.xz mpd-fe7cda57e46aa133cf84abc76308388bbf091cbb.zip |
util/PeakBuffer: fix nullptr dereference when peak_size==0
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/PeakBuffer.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util/PeakBuffer.cxx b/src/util/PeakBuffer.cxx index 8358949c1..e4624bbec 100644 --- a/src/util/PeakBuffer.cxx +++ b/src/util/PeakBuffer.cxx @@ -122,8 +122,9 @@ PeakBuffer::Append(const void *data, size_t length) return true; } - if (peak_buffer == nullptr && peak_size > 0) { - peak_buffer = new DynamicFifoBuffer<uint8_t>(peak_size); + if (peak_buffer == nullptr) { + if (peak_size > 0) + peak_buffer = new DynamicFifoBuffer<uint8_t>(peak_size); if (peak_buffer == nullptr) return false; } |