From 006b8fa3f07e948cbd277e91546dd815769d7a5e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 28 Nov 2011 22:00:17 +0100 Subject: 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. --- src/pcm_buffer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/pcm_buffer.c') diff --git a/src/pcm_buffer.c b/src/pcm_buffer.c index a71a10cb..c2215735 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); -- cgit v1.2.3