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.
This commit is contained in:
Max Kellermann
2012-02-13 18:05:42 +01:00
parent 9c92afa5fe
commit 7855a32579
3 changed files with 10 additions and 0 deletions

View File

@@ -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);