music_buffer: poison unallocated chunks
When a music chunk is freed (returned to the buffer), poison its memory.
This commit is contained in:
parent
940af669b3
commit
c5c86452ce
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "chunk.h"
|
#include "chunk.h"
|
||||||
|
#include "poison.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -51,10 +52,12 @@ music_buffer_new(unsigned num_chunks)
|
|||||||
buffer->num_chunks = num_chunks;
|
buffer->num_chunks = num_chunks;
|
||||||
|
|
||||||
chunk = buffer->available = buffer->chunks;
|
chunk = buffer->available = buffer->chunks;
|
||||||
|
poison_undefined(chunk, sizeof(*chunk));
|
||||||
|
|
||||||
for (unsigned i = 1; i < num_chunks; ++i) {
|
for (unsigned i = 1; i < num_chunks; ++i) {
|
||||||
chunk->next = &buffer->chunks[i];
|
chunk->next = &buffer->chunks[i];
|
||||||
chunk = chunk->next;
|
chunk = chunk->next;
|
||||||
|
poison_undefined(chunk, sizeof(*chunk));
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk->next = NULL;
|
chunk->next = NULL;
|
||||||
@ -116,6 +119,8 @@ music_buffer_return(struct music_buffer *buffer, struct music_chunk *chunk)
|
|||||||
g_mutex_lock(buffer->mutex);
|
g_mutex_lock(buffer->mutex);
|
||||||
|
|
||||||
music_chunk_free(chunk);
|
music_chunk_free(chunk);
|
||||||
|
poison_undefined(chunk, sizeof(*chunk));
|
||||||
|
|
||||||
chunk->next = buffer->available;
|
chunk->next = buffer->available;
|
||||||
buffer->available = chunk;
|
buffer->available = chunk;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user