# HG changeset patch # User reimar # Date 1184594513 0 # Node ID 4decd04037b4d6f585b548188241340f9b86963f # Parent d484cdfcb8a84cd9b62b6f5a580668d050bb8142 Avoid crash if a non-existent audio track is selected with -aid diff -r d484cdfcb8a8 -r 4decd04037b4 libmpdemux/demux_mkv.c --- 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;