aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-01 08:33:53 +0200
committerMax Kellermann <max@duempel.org>2013-08-01 08:33:53 +0200
commit105b431e4cd5416b44ed3fb68e5944ad59bd8221 (patch)
tree5505e9758575d92a10ac9e8b2cc66a0151e831a0
parentba79f4c1f9b9868db04ece3c8870085a25915556 (diff)
downloadmpd-105b431e4cd5416b44ed3fb68e5944ad59bd8221.tar.gz
mpd-105b431e4cd5416b44ed3fb68e5944ad59bd8221.tar.xz
mpd-105b431e4cd5416b44ed3fb68e5944ad59bd8221.zip
PcmBuffer: reset size in Clear()
Fix for Mantis #3806. "PcmBuffer::Clear clears the buffer but does not reset the size. If Get is called on the same PcmBuffer later on with a size that is the same as (or less than) it was before the call to Clear, the "else" branch is taken and the memory of buffer (at the address of nullptr) is poisoned instead of the necessary allocation being performed. A memset or memcpy on the returned pointer (nullptr) causes a segmentation fault."
-rw-r--r--src/pcm/PcmBuffer.hxx1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pcm/PcmBuffer.hxx b/src/pcm/PcmBuffer.hxx
index 260960726..ae7030f76 100644
--- a/src/pcm/PcmBuffer.hxx
+++ b/src/pcm/PcmBuffer.hxx
@@ -46,6 +46,7 @@ struct PcmBuffer {
void Clear() {
g_free(buffer);
buffer = nullptr;
+ size = 0;
}
/**