Prevent error condition in case sample_rate is unset or set to a negative
value. In particular, fix divide-by-zero error occurring in ffmpeg due to
sample_rate set to 0 in output_packet(), in code:
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
ist->st->codec->sample_rate;
Fix trac ticket #324.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -59,6 +59,12 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) |
59 | 59 |
|
60 | 60 |
if (s1->sample_rate) |
61 | 61 |
st->codec->sample_rate = s1->sample_rate; |
62 |
+ if (st->codec->sample_rate <= 0) { |
|
63 |
+ av_log(s, AV_LOG_ERROR, "Invalid sample rate %d specified\n", |
|
64 |
+ st->codec->sample_rate); |
|
65 |
+ return AVERROR(EINVAL); |
|
66 |
+ } |
|
67 |
+ |
|
62 | 68 |
if (s1->channels) |
63 | 69 |
st->codec->channels = s1->channels; |
64 | 70 |
|