From 9848c1a1a1857424e8959932d10fa8b39a044b3e Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 12 Aug 2022 05:00:32 +1000 Subject: [PATCH] m3u8demux2: Fix off-by-one and leak. Fix an off-by-one in gst_hls_media_playlist_sync_to_playlist() that would ignore the first fragment in the reference playlist. The error was harmless, since we expect the reference playlist to be older than the playlist we're synchronising (so the first/oldest segment in the reference playlist will likely not exist in the new playlist), so this is just for correctness. Also fix a segment leak in gst_hls_media_playlist_advance_fragment() when ignoring the partial_only segment. Part-of: --- subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c index 8b983600e8..57f9904348 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c @@ -1830,8 +1830,8 @@ retry_without_dsn: * or a more recently fetched playlist from another rendition. In either case, * it's best to start from the last segment of the (older) reference playlist and * go backwards to find an overlap */ - for (idx = reference->segments->len - 1; idx; idx--) { - cand = g_ptr_array_index (reference->segments, idx); + for (idx = reference->segments->len; idx; idx--) { + cand = g_ptr_array_index (reference->segments, idx - 1); res = find_segment_in_playlist (playlist, cand, &is_before, &matched_pdt); if (res) break; @@ -1957,6 +1957,7 @@ gst_hls_media_playlist_advance_fragment (GstHLSMediaPlaylist * m3u8, if (file && file->partial_only && !allow_partial_only_segment) { GST_LOG ("Ignoring segment with only partials as full segment was requested"); + gst_m3u8_media_segment_unref (file); file = NULL; }