From e938637b2ca7587c2b349458189f1f7d7da87040 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 13 Sep 2007 05:59:58 +0000 Subject: Add checks on input/output buffers size for some audio decoders Originally committed as revision 10485 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/truespeech.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libavcodec/truespeech.c') diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index a03f2a0ced..eafbdf7a01 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -333,15 +333,17 @@ static int truespeech_decode_frame(AVCodecContext *avctx, { TSContext *c = avctx->priv_data; - int i; + int i, j; short *samples = data; int consumed = 0; int16_t out_buf[240]; + int iterations; if (!buf_size) return 0; - while (consumed < buf_size) { + iterations = FFMIN(buf_size / 32, *data_size / 480); + for(j = 0; j < iterations; j++) { truespeech_read_frame(c, buf + consumed); consumed += 32; @@ -366,7 +368,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx, *data_size = consumed * 15; - return buf_size; + return consumed; } AVCodec truespeech_decoder = { -- cgit v1.2.3