From 4b6c00c50ad7739c024662be0321eef8015b5829 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 Nov 2013 17:20:56 +0100 Subject: tl_matroska: initialize segment related arrays with 0 mpv crashed when linked files were not found. The reason was that the chapters array contained some uninitialized data. I have no idea how this code works (after the merge). The old code actually seems to remove missing chapters, while the new code just leaves them unintiialized. Work around the crash by initializing the chapters array (and a bunch of other things) with 0, which means the missing chapter will be located at 00:00:00 and have no name. There is a regression since commit af0306d. --- mpvcore/player/timeline/tl_matroska.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mpvcore/player/timeline/tl_matroska.c b/mpvcore/player/timeline/tl_matroska.c index 5a96cfe5f1..2ecc292a84 100644 --- a/mpvcore/player/timeline/tl_matroska.c +++ b/mpvcore/player/timeline/tl_matroska.c @@ -506,11 +506,12 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) // +1 because sources/uid_map[0] is original file even if all chapters // actually use other sources and need separate entries - struct demuxer **sources = talloc_array_ptrtype(NULL, sources, + struct demuxer **sources = talloc_zero_array(NULL, struct demuxer *, m->num_ordered_chapters+1); sources[0] = mpctx->demuxer; - struct matroska_segment_uid *uids = talloc_array_ptrtype(NULL, uids, - m->num_ordered_chapters + 1); + struct matroska_segment_uid *uids = + talloc_zero_array(NULL, struct matroska_segment_uid, + m->num_ordered_chapters + 1); int num_sources = 1; memcpy(uids[0].segment, m->uid.segment, 16); uids[0].edition = 0; @@ -537,7 +538,8 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx) talloc_free(uids); struct timeline_part *timeline = talloc_array_ptrtype(NULL, timeline, 0); - struct chapter *chapters = talloc_array_ptrtype(NULL, chapters, m->num_ordered_chapters); + struct chapter *chapters = + talloc_zero_array(NULL, struct chapter, m->num_ordered_chapters); uint64_t starttime = 0; uint64_t missing_time = 0; uint64_t last_end_time = 0; -- cgit v1.2.3