From: Andre Noll Date: Mon, 1 Dec 2008 20:18:41 +0000 (+0100) Subject: mp3dec: Only proceed decoding if at least 16K are available. X-Git-Tag: v0.3.4~92 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=e0b7f590a37c672994946405e19385bb8f4bbb37;ds=sidebyside mp3dec: Only proceed decoding if at least 16K are available. This is safe because the output buffer size is at least 32K. --- diff --git a/mp3dec_filter.c b/mp3dec_filter.c index d3265d4f..e9d84c1b 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -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 */