From 7cc16b64b7085804dae01f9e2bdf8ac315eca4bd Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Wed, 9 Oct 2024 16:23:47 +0300 Subject: [PATCH] mxfdemux: Keep tracking the offsets even when an index table was found Some files may contain a partial index table, leading into a crash when you try seeking in them Part-of: --- subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c b/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c index 6153e89a20..be55cd7110 100644 --- a/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c +++ b/subprojects/gst-plugins-bad/gst/mxf/mxfdemux.c @@ -2875,6 +2875,9 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux, return ret; } + if (!etrack->offsets) + etrack->offsets = g_array_new (FALSE, TRUE, sizeof (GstMXFDemuxIndex)); + if (!index_entry.initialized) { /* This can happen when doing scanning without entry tables */ index_entry.duration = 1; @@ -2890,12 +2893,11 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux, etrack->track_id, index_entry.dts, index_entry.offset, index_entry.keyframe); - if (!etrack->offsets) - etrack->offsets = g_array_new (FALSE, TRUE, sizeof (GstMXFDemuxIndex)); - /* We only ever append to the track offset entry. */ g_assert (etrack->position <= etrack->offsets->len); g_array_insert_val (etrack->offsets, etrack->position, index_entry); + } else if (etrack->position == etrack->offsets->len) { + g_array_insert_val (etrack->offsets, etrack->position, index_entry); } if (peek)