diff options
author | Laurent Aimar <fenrir@videolan.org> | 2011-09-12 21:09:57 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-12 21:45:23 +0200 |
commit | c58d45e00489e07fd4606b64ad4095660494185b (patch) | |
tree | d088781e0c5739b3ccf6f8dbd046b41f99357bea | |
parent | 7cbe02575868e7d25acf3d319ece664702700f0a (diff) | |
download | ffmpeg-c58d45e00489e07fd4606b64ad4095660494185b.tar.gz |
segafilm: Fix potential division by 0 on corrupted segafilm streams in the demuxer.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/segafilm.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 00a248ed26..15234c70d6 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -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; } @@ -201,7 +204,7 @@ static int film_read_header(AVFormatContext *s, if (film->audio_type == CODEC_ID_ADPCM_ADX) audio_frame_counter += (film->sample_table[i].sample_size * 32 / (18 * film->audio_channels)); - else + else if (film->audio_type != CODEC_ID_NONE) audio_frame_counter += (film->sample_table[i].sample_size / (film->audio_channels * film->audio_bits / 8)); } else { |