Commit 7855a325 authored by Max Kellermann's avatar Max Kellermann

pcm_buffer: pcm_buffer_get() never returns NULL

This fixes a bug when libsamplerate returns an empty buffer for a very small input buffer. The caller thinks this is an error, bug there is no GError object.
parent 9c92afa5
ver 0.16.8 (2012/??/??)
* fix for libsamplerate assertion failure
ver 0.16.7 (2012/02/04)
......
......@@ -34,6 +34,11 @@ pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
{
assert(buffer != NULL);
if (size == 0)
/* never return NULL, because NULL would be assumed to
be an error condition */
size = 1;
if (buffer->size < size) {
/* free the old buffer */
g_free(buffer->buffer);
......
......@@ -63,6 +63,10 @@ pcm_buffer_deinit(struct pcm_buffer *buffer)
/**
* Get the buffer, and guarantee a minimum size. This buffer becomes
* invalid with the next pcm_buffer_get() call.
*
* This function will never return NULL, even if size is zero, because
* the PCM library uses the NULL return value to signal "error". An
* empty destination buffer is not always an error.
*/
G_GNUC_MALLOC
void *
......
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