rtpjitterbuffer: Properly free internal packets queue in finalize()
authorSebastian Dröge <sebastian@centricular.com>
Wed, 22 Apr 2020 11:09:37 +0000 (14:09 +0300)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 22 Apr 2020 14:28:30 +0000 (10:28 -0400)
commit7b22397cf5577076cf45cd512bc52b02250caed0
tree25eadcdbb0b30d93cccb0fc88dd6cf1f0a11a095
parentea1797ccb5d1b9c046b498db55ee2fc832cc4664
rtpjitterbuffer: Properly free internal packets queue in finalize()

As we override the GLib item with our own structure, we cannot use any
function from GList or GQueue that would try to free the RTPJitterBufferItem.
In this patch, we move away from g_queue_new() which forces using
g_queue_free(). This this function could use g_slice_free() if there is any items
left in the queue. Passing the wrong size to GSLice may cause data corruption
and crash.

A better approach would be to use a proper intrusive linked list
implementation but that's left as an exercise for the next person
running into crashes caused by this.

Be ware that this regression was introduced 6 years ago in the following
commit [0], the call to flush() looked useless, as there was a g_queue_free()
afterward.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
[0] https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/479c7642fd953edf1291a0ed4a3d53618418019c

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/573>
gst/rtpmanager/rtpjitterbuffer.c
gst/rtpmanager/rtpjitterbuffer.h