matroskadec: check audio sample rate
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Mon, 15 Jun 2015 18:59:22 +0000 (20:59 +0200)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Tue, 16 Jun 2015 19:45:45 +0000 (21:45 +0200)
And default to 8000 if it is invalid.

An invalid sample rate can trigger av_assert2 in av_rescale_rnd.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavformat/matroskadec.c

index 3512f0f..81dd53f 100644 (file)
@@ -1680,6 +1680,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
         if (!track->codec_id)
             continue;
 
+        if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX ||
+            isnan(track->audio.samplerate)) {
+            av_log(matroska->ctx, AV_LOG_WARNING,
+                   "Invalid sample rate %f, defaulting to 8000 instead.\n",
+                   track->audio.samplerate);
+            track->audio.samplerate = 8000;
+        }
+
         if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
             if (!track->default_duration && track->video.frame_rate > 0)
                 track->default_duration = 1000000000 / track->video.frame_rate;