aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_buffer.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-11-28 22:00:17 +0100
committerMax Kellermann <max@duempel.org>2011-12-13 19:55:41 +0100
commit006b8fa3f07e948cbd277e91546dd815769d7a5e (patch)
tree80d9ea3a5c8b58b698c162bebf4959adb3fb698b /src/pcm_buffer.c
parent6a01153ce4189d21f7efe87305a4e22cb8346eea (diff)
downloadmpd-006b8fa3f07e948cbd277e91546dd815769d7a5e.tar.gz
mpd-006b8fa3f07e948cbd277e91546dd815769d7a5e.tar.xz
mpd-006b8fa3f07e948cbd277e91546dd815769d7a5e.zip
pcm_buffer: poison the old buffer before returning it
Make valgrind find more buffer misuses. Buffer contents are not persistent, they get invalidated by pcm_buffer_get(), because this function may allocate a new buffer, but will not copy old data.
Diffstat (limited to '')
-rw-r--r--src/pcm_buffer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pcm_buffer.c b/src/pcm_buffer.c
index a71a10cb3..c22157352 100644
--- a/src/pcm_buffer.c
+++ b/src/pcm_buffer.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "pcm_buffer.h"
+#include "poison.h"
/**
* Align the specified size to the next 8k boundary.
@@ -41,6 +42,9 @@ pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
buffer->size = align_8k(size);
buffer->buffer = g_malloc(buffer->size);
+ } else {
+ /* discard old buffer contents */
+ poison_undefined(buffer->buffer, buffer->size);
}
assert(buffer->size >= size);