From 57f12dd2fa28c1cbf3d99a1dbca66895781dfe55 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 15 Feb 2024 09:15:50 -0500 Subject: [PATCH] bus: do not leak messages if there is no async handler This does not typically happen because "enable-async" property is TRUE by default. The only place where it is set to FALSE is in GstBin where a sync handler is used and always returns GST_BUS_DROP. Part-of: --- subprojects/gstreamer/gst/gstbus.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/subprojects/gstreamer/gst/gstbus.c b/subprojects/gstreamer/gst/gstbus.c index 4bf12ad5d1..59813ad811 100644 --- a/subprojects/gstreamer/gst/gstbus.c +++ b/subprojects/gstreamer/gst/gstbus.c @@ -366,10 +366,13 @@ gst_bus_post (GstBus * bus, GstMessage * message) g_clear_pointer (&sync_handler, sync_handler_unref); - /* If this is a bus without async message delivery - * always drop the message */ - if (!bus->priv->poll) + /* If this is a bus without async message delivery always drop the message. + * If the sync handler returned GST_BUS_DROP it is responsible of unreffing + * the message, otherwise do it ourself. */ + if (!bus->priv->poll && reply != GST_BUS_DROP) { reply = GST_BUS_DROP; + gst_message_unref (message); + } /* now see what we should do with the message */ switch (reply) {