Commit c5c86452 authored by Max Kellermann's avatar Max Kellermann

music_buffer: poison unallocated chunks

When a music chunk is freed (returned to the buffer), poison its memory.
parent 940af669
...@@ -18,6 +18,7 @@ ...@@ -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) ...@@ -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) ...@@ -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;
......
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