From: Edward Hervey Date: Thu, 1 Dec 2016 16:08:09 +0000 (+0100) Subject: jitterbuffer: Don't leak duplicate items X-Git-Tag: 1.12.2~284 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5158ca496ea90a273fb8eeec098a7f0e60671ff;p=platform%2Fupstream%2Fgst-plugins-good.git jitterbuffer: Don't leak duplicate items When providing items with a seqnum, there is a (very small) probability that an element with the same seqnum already exists. Don't forget to free that item if it wasn't inserted. And avoid returning undefined values when dealing with duplicate items --- diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index a6e0b3af8..2ca9fe742 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -3757,7 +3757,9 @@ do_lost_timeout (GstRtpJitterBuffer * jitterbuffer, TimerData * timer, "retry", G_TYPE_UINT, num_rtx_retry, NULL)); } item = alloc_item (event, ITEM_TYPE_LOST, -1, -1, seqnum, lost_packets, -1); - rtp_jitter_buffer_insert (priv->jbuf, item, &head, NULL); + if (!rtp_jitter_buffer_insert (priv->jbuf, item, &head, NULL)) + /* Duplicate */ + free_item (item); if (GST_CLOCK_TIME_IS_VALID (timer->rtx_last)) { /* Store info to update stats if the packet arrives too late */ diff --git a/gst/rtpmanager/rtpjitterbuffer.c b/gst/rtpmanager/rtpjitterbuffer.c index c31c8e64b..03b7ebc1e 100644 --- a/gst/rtpmanager/rtpjitterbuffer.c +++ b/gst/rtpmanager/rtpjitterbuffer.c @@ -1034,6 +1034,8 @@ append: duplicate: { GST_DEBUG ("duplicate packet %d found", (gint) seqnum); + if (G_LIKELY (head)) + *head = FALSE; return FALSE; } }