From 0b20ffa0592bcc0414d732ed3475e337bbc1c0b1 Mon Sep 17 00:00:00 2001
From: Daniel Kang <daniel.d.kang@gmail.com>
Date: Fri, 7 Jan 2011 07:52:37 -0500
Subject: [PATCH] Add check for number of channels in ts files.

---
 libavcodec/dca.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index 868fe2f..8ade1a0 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -1760,6 +1760,10 @@ static int dca_decode_frame(AVCodecContext * avctx,
        unset. Ideally during the first probe for channels the crc should be checked
        and only set avctx->channels when the crc is ok. Right now the decoder could
        set the channels based on a broken first frame.*/
+    if (channels > DCA_PRIM_CHANNELS_MAX) {
+        av_log(avctx, AV_LOG_ERROR, "Invalid number of channels (%d). Corrupted file?\n", channels);
+        return -1;
+    }
     avctx->channels = channels;

     if (*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
--
1.7.2.2
