gstbin: Fix a potential leak in gst_bin_do_deep_add_remove()
authorJan Schmidt <jan@centricular.com>
Fri, 30 Sep 2022 18:55:49 +0000 (04:55 +1000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 4 Oct 2022 11:19:14 +0000 (11:19 +0000)
If a child element of a bin is unparented while
gst_bin_do_deep_add_remove() is iterating the children,
don't leak a ref to it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3101>

subprojects/gstreamer/gst/gstbin.c

index 116bd0f..4233841 100644 (file)
@@ -1142,8 +1142,9 @@ gst_bin_do_deep_add_remove (GstBin * bin, gint sig_id, const gchar * sig_name,
               " in bin %" GST_PTR_FORMAT, sig_name, e, parent);
           g_signal_emit (bin, sig_id, 0, parent, e);
           gst_object_unref (parent);
-          gst_object_unref (e);
         }
+
+        gst_object_unref (e);
       }
     }
     gst_iterator_free (it);