From ad80cc4eeec506fddd11e2a29d0b1868b3ca8170 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Wed, 16 Dec 2015 23:40:21 -0800 Subject: demux_cue: remove cue tracks which have a null filename. This can happen if the file references a track, but does not specify an INDEX 01 for it. This would cause mpv to just segfault due to dereferencing the null pointer as a string. A file causing this was observed in the wild by ExactAudioCopy v0.99pb4 for a disk that contained a data track at the end. --- demux/demux_cue.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/demux/demux_cue.c b/demux/demux_cue.c index 43420573ec..da84fc60c1 100644 --- a/demux/demux_cue.c +++ b/demux/demux_cue.c @@ -150,8 +150,18 @@ static void build_timeline(struct timeline *tl) add_source(tl, tl->demuxer); - struct cue_track *tracks = p->f->tracks; - size_t track_count = p->f->num_tracks; + struct cue_track *tracks = NULL; + size_t track_count = 0; + + for (size_t n = 0; n < p->f->num_tracks; n++) { + struct cue_track *track = &p->f->tracks[n]; + if (track->filename) { + MP_TARRAY_APPEND(ctx, tracks, track_count, *track); + } else { + MP_WARN(tl->demuxer, "No file specified for track entry %zd. " + "It will be removed\n", n + 1); + } + } if (track_count == 0) { MP_ERR(tl, "CUE: no tracks found!\n"); -- cgit v1.2.3