From 792fb05cecce378ca03a4e4b5b1ea548a034d15f Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 12 Nov 2021 03:17:44 +0100 Subject: [PATCH] st2022-1-fecdec: fix packet trimming g_sequence_remove_range's end iter is exclusive, so if one wants to remove that item as well, it should be called with the next iter. This could in theory fix an issue where: * The sequence isn't entirely trimmed, with an old item lingering * Following FEC packets are immediately discarded because they arrived later than corresponding media packets, long enough for seqnums to wrap around * We now try to reconstruct a media packet with a completely obsolete FEC packet, chaos ensues. Part-of: --- .../gst-plugins-good/gst/rtpmanager/gstrtpst2022-1-fecdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpst2022-1-fecdec.c b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpst2022-1-fecdec.c index ca9884f4ae..77b275fb1b 100644 --- a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpst2022-1-fecdec.c +++ b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtpst2022-1-fecdec.c @@ -221,7 +221,8 @@ trim_items (GstRTPST_2022_1_FecDec * dec) GST_TRACE_OBJECT (dec, "Trimming packets up to %" GST_TIME_FORMAT " (seq: %u)", GST_TIME_ARGS (GST_BUFFER_DTS_OR_PTS (item->buffer)), item->seq); - g_sequence_remove_range (g_sequence_get_begin_iter (dec->packets), iter); + g_sequence_remove_range (g_sequence_get_begin_iter (dec->packets), + g_sequence_iter_next (iter)); } } @@ -263,7 +264,7 @@ trim_fec_items (GstRTPST_2022_1_FecDec * dec, guint D) D ? "row" : "column", GST_TIME_ARGS (GST_BUFFER_DTS_OR_PTS (item->buffer)), item->seq); g_sequence_remove_range (g_sequence_get_begin_iter (dec->fec_packets[D]), - iter); + g_sequence_iter_next (iter)); } }