changeset 23770:4decd04037b4

Avoid crash if a non-existent audio track is selected with -aid
author reimar
date Mon, 16 Jul 2007 14:01:53 +0000
parents d484cdfcb8a8
children 1ddf3b0122fb
files libmpdemux/demux_mkv.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Mon Jul 16 11:34:18 2007 +0000
+++ b/libmpdemux/demux_mkv.c	Mon Jul 16 14:01:53 2007 +0000
@@ -2520,6 +2520,11 @@
   else if (demuxer->audio->id != -2)  /* -2 = no audio at all */
     track = demux_mkv_find_track_by_num (mkv_d, demuxer->audio->id,
                                          MATROSKA_TRACK_AUDIO);
+  if (track && demuxer->a_streams[track->tnum])
+    {
+      demuxer->audio->id = track->tnum;
+      demuxer->audio->sh = demuxer->a_streams[track->tnum];
+    }
   else
     {
       mp_msg (MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_NoAudioTrackFound);
@@ -2534,11 +2539,6 @@
           continue;
       if(demuxer->a_streams[track->tnum])
         {
-          if(track && mkv_d->tracks[i] == track)
-            {
-              demuxer->audio->id = track->tnum;
-              demuxer->audio->sh = demuxer->a_streams[track->tnum];
-            }
           mkv_d->last_aid++;
           if(mkv_d->last_aid == MAX_A_STREAMS)
             break;