Commit 006b8fa3 authored by Max Kellermann's avatar Max Kellermann

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.
parent 6a01153c
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment