From 406e8f3fe36101a216901e1326815dbfec03292c Mon Sep 17 00:00:00 2001 From: Sebastian Gross Date: Mon, 22 Jul 2024 09:29:52 +0200 Subject: [PATCH] asfdemux: Be more lenient towards malformed header VLC counts METADATA as 1 even if the specification states you must not. This leads to asfdemux failing since there are no bytes left when asfdemux tries to extract the "last" header. Do not fail hard in this case and try to proceed when everything else went fine. So at least gst-discoverer will see what's in the file. Closes #3684 Part-of: --- .../gst-plugins-ugly/gst/asfdemux/gstasfdemux.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/subprojects/gst-plugins-ugly/gst/asfdemux/gstasfdemux.c b/subprojects/gst-plugins-ugly/gst/asfdemux/gstasfdemux.c index 628545ca34..3a6bc9a6b1 100644 --- a/subprojects/gst-plugins-ugly/gst/asfdemux/gstasfdemux.c +++ b/subprojects/gst-plugins-ugly/gst/asfdemux/gstasfdemux.c @@ -3712,6 +3712,16 @@ gst_asf_demux_process_header (GstASFDemux * demux, guint8 * data, guint64 size) demux->saw_file_header = FALSE; /* Loop through the header's objects, processing those */ for (i = 0; i < num_objects; ++i) { + + /* Do not try to process non existent header and accept the num_objects was + * too high (as VLC counts METADATA object even if it shouldn't) and proceed + * normally */ + if (size == 0) { + GST_WARNING_OBJECT (demux, "No bytes left for header part %u: Skipping", + i); + break; + } + GST_INFO_OBJECT (demux, "reading header part %u", i); ret = gst_asf_demux_process_object (demux, &data, &size); if (ret != GST_FLOW_OK) {