segafilm: Fix potential division by 0 on corrupted streams in the demuxer
authorLaurent Aimar <fenrir@videolan.org>
Mon, 12 Sep 2011 19:09:57 +0000 (21:09 +0200)
committerJanne Grunau <janne-libav@jannau.net>
Thu, 6 Oct 2011 21:01:45 +0000 (23:01 +0200)
Signed-off-by: Janne Grunau <janne-libav@jannau.net>
libavformat/segafilm.c

index 32a979f..ea464f2 100644 (file)
@@ -113,11 +113,14 @@ static int film_read_header(AVFormatContext *s,
         film->audio_bits = scratch[22];
         if (scratch[23] == 2)
             film->audio_type = CODEC_ID_ADPCM_ADX;
-        else if (film->audio_bits == 8)
-            film->audio_type = CODEC_ID_PCM_S8;
-        else if (film->audio_bits == 16)
-            film->audio_type = CODEC_ID_PCM_S16BE;
-        else
+        else if (film->audio_channels > 0) {
+            if (film->audio_bits == 8)
+                film->audio_type = CODEC_ID_PCM_S8;
+            else if (film->audio_bits == 16)
+                film->audio_type = CODEC_ID_PCM_S16BE;
+            else
+                film->audio_type = CODEC_ID_NONE;
+        } else
             film->audio_type = CODEC_ID_NONE;
     }