[FFmpeg-cvslog] rawdec: add check on sample_rate
Stefano Sabatini
git at videolan.org
Fri Oct 28 02:08:52 CEST 2011
ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Thu Oct 27 01:38:21 2011 +0200| [aa638b4600e1fa7a1b64323b8228c459af644a47] | committer: Stefano Sabatini
rawdec: add check on sample_rate
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa638b4600e1fa7a1b64323b8228c459af644a47
---
libavformat/rawdec.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index 37e9b0c..a270ccd 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -56,6 +56,12 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (s1 && s1->sample_rate)
st->codec->sample_rate = s1->sample_rate;
+ if (st->codec->sample_rate <= 0) {
+ av_log(s, AV_LOG_ERROR, "Invalid sample rate %d specified\n",
+ st->codec->sample_rate);
+ return AVERROR(EINVAL);
+ }
+
if (s1 && s1->channels)
st->codec->channels = s1->channels;
More information about the ffmpeg-cvslog
mailing list