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.
This commit is contained in:
parent
6a01153ce4
commit
006b8fa3f0
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user