matroska-demux: Prevent corrupt cluster duplication

Make sure to always update next_cluster_offset, if next cluster offset
isn't known set it to zero. If next_cluster_offfset isn't updated it will
be the same as current and if the cluster parsing fails the same cluster
will be parsed again leading to duplication of the data in the cluster.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8855>
This commit is contained in:
Stefan Andersson 2025-04-16 11:58:45 +02:00
parent 24bcff5650
commit 1c8b01ccbc

View File

@ -6033,9 +6033,11 @@ gst_matroska_demux_parse_id (GstMatroskaDemux * demux, guint32 id,
demux->seek_block = 0;
}
demux->seek_first = FALSE;
/* record next cluster for recovery */
/* record next cluster for recovery, set to 0 if offset isn't known. */
if (read != G_MAXUINT64)
demux->next_cluster_offset = demux->cluster_offset + read;
else
demux->next_cluster_offset = 0;
/* eat cluster prefix */
gst_matroska_demux_flush (demux, needed);
break;