mp3dec: Only proceed decoding if at least 16K are available.
authorAndre Noll <maan@systemlinux.org>
Mon, 1 Dec 2008 20:18:41 +0000 (21:18 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 1 Dec 2008 20:18:41 +0000 (21:18 +0100)
This is safe because the output buffer size is at least 32K.

mp3dec_filter.c

index d3265d4..e9d84c1 100644 (file)
@@ -35,7 +35,7 @@ static ssize_t mp3dec(char *inbuffer, size_t len, struct filter_node *fn)
        struct private_mp3dec_data *pmd = fn->private_data;
        size_t copy = PARA_MIN(len, 4096);
 
-       if (fn->loaded > fn->bufsize * 4 / 5)
+       if (fn->loaded + 16384 > fn->bufsize)
                return 0;
        mad_stream_buffer(&pmd->stream, (unsigned char *) inbuffer, copy);
        pmd->stream.error = 0;
@@ -78,7 +78,7 @@ next_frame:
                PARA_ERROR_LOG("output buffer full: %zd\n", fn->loaded);
                        return -E_MP3DEC_OVERRUN;
        }
-       if (fn->loaded <= fn->bufsize * 4 / 5)
+       if (fn->loaded + 16384 <= fn->bufsize)
                goto next_frame;
 out:
        if (pmd->stream.next_frame) { /* we still have some data */