From db48f42532d8e3994d67ccf9c05f37bfc4e3ed28 Mon Sep 17 00:00:00 2001
From: Daniel Kang <daniel.d.kang@gmail.com>
Date: Sat, 8 Jan 2011 22:30:17 -0500
Subject: [PATCH] dct sanity check for number of channels

---
 libavformat/electronicarts.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index df517df..81431f0 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -173,6 +173,11 @@ static int process_audio_header_elements(AVFormatContext *s)
         }
     }

+    if (ea->num_channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "Unsupported number of channels: %d\n", ea->num_channels);
+        return AVERROR(EINVAL);
+    }
+
     switch (compression_type) {
     case  0: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
     case  7: ea->audio_codec = CODEC_ID_ADPCM_EA; break;
@@ -224,6 +229,11 @@ static int process_audio_header_eacs(AVFormatContext *s)
     compression_type = get_byte(pb);
     url_fskip(pb, 13);

+    if (ea->num_channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "Unsupported number of channels: %d\n", ea->num_channels);
+        return AVERROR(EINVAL);
+    }
+
     switch (compression_type) {
     case 0:
         switch (ea->bytes) {
@@ -254,6 +264,11 @@ static int process_audio_header_sead(AVFormatContext *s)
     ea->num_channels = get_le32(pb);
     ea->audio_codec  = CODEC_ID_ADPCM_IMA_EA_SEAD;

+    if (ea->num_channels <= 0) {
+        av_log(s, AV_LOG_ERROR, "Unsupported number of channels: %d\n", ea->num_channels);
+        return AVERROR(EINVAL);
+    }
+
     return 1;
 }

--
1.7.2.2

