History

segafilm: Fix potential division by 0 on corrupted segafilm streams in the demuxer.

Laurent Aimar committed 15 years ago

Commit c58d45e1 parent 7cbe0251 file · +9 −6Browse files

Unified · Split

libavformat/segafilm.c+9−6
@@ -113,11 +113,14 @@ static int film_read_header(AVFormatContext *s, · 112 unmodified lines
113113 film->audio_bits = scratch[22];
114114 if (scratch[23] == 2)
115115 film->audio_type = CODEC_ID_ADPCM_ADX;
116− else if (film->audio_bits == 8)
117− film->audio_type = CODEC_ID_PCM_S8;
118− else if (film->audio_bits == 16)
119− film->audio_type = CODEC_ID_PCM_S16BE;
120− else
116+ else if (film->audio_channels > 0) {
117+ if (film->audio_bits == 8)
118+ film->audio_type = CODEC_ID_PCM_S8;
119+ else if (film->audio_bits == 16)
120+ film->audio_type = CODEC_ID_PCM_S16BE;
121+ else
122+ film->audio_type = CODEC_ID_NONE;
123+ } else
121124 film->audio_type = CODEC_ID_NONE;
122125 }
123126
@@ -201,7 +204,7 @@ static int film_read_header(AVFormatContext *s, · 77 unmodified lines
201204 if (film->audio_type == CODEC_ID_ADPCM_ADX)
202205 audio_frame_counter += (film->sample_table[i].sample_size * 32 /
203206 (18 * film->audio_channels));
204− else
207+ else if (film->audio_type != CODEC_ID_NONE)
205208 audio_frame_counter += (film->sample_table[i].sample_size /
206209 (film->audio_channels * film->audio_bits / 8));
207210 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t