From d752bf1b462ca348307fc0363e80aebc8072c306 Mon Sep 17 00:00:00 2001 From: Patricia Muscalu Date: Thu, 22 Dec 2022 11:16:26 +0100 Subject: [PATCH] qtmux: Fix buffer leak in fragment_buffers When pushing buffers from one of the sink pads fail, make sure that all buffers added to fragment_buffers on other pads are freed as well. Part-of: --- subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c b/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c index 3bab8a3729..5f6cf80b5e 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c +++ b/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c @@ -641,6 +641,8 @@ gst_qt_mux_class_init (GstQTMuxClass * klass) static void gst_qt_mux_pad_reset (GstQTMuxPad * qtpad) { + guint i; + qtpad->fourcc = 0; qtpad->is_out_of_order = FALSE; qtpad->sample_size = 0; @@ -678,7 +680,13 @@ gst_qt_mux_pad_reset (GstQTMuxPad * qtpad) atom_traf_free (qtpad->traf); qtpad->traf = NULL; } + for (i = 0; i < atom_array_get_len (&qtpad->fragment_buffers); i++) { + GstBuffer *buf = atom_array_index (&qtpad->fragment_buffers, i); + if (buf != NULL) + gst_buffer_unref (atom_array_index (&qtpad->fragment_buffers, i)); + } atom_array_clear (&qtpad->fragment_buffers); + if (qtpad->samples) g_array_unref (qtpad->samples); qtpad->samples = NULL;