From 2fcb90f661142ef7621a17f64f2127dc08cbda2b Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Tue, 2 Jul 2024 20:30:48 +0200 Subject: [PATCH] gst: stream: Destroy stream before clearing variable `pw_stream_destroy()` chains up to `on_remove_buffer()` in GstPipeWireSrc which again needs the stream to still be around to call `pw_stream_queue_buffer()` on it. By using `g_clear_pointer()` it will already have been cleared, causing crashes. Revert to the behavior from before the commit mentioned below and add a comment in order to avoid regressing in a future cleanup. Fixes: 0c40c0147 (gst: factor out the stream management and some common variables in a new class) --- src/gst/gstpipewirestream.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gst/gstpipewirestream.c b/src/gst/gstpipewirestream.c index 4cadcd5c8..bf7641548 100644 --- a/src/gst/gstpipewirestream.c +++ b/src/gst/gstpipewirestream.c @@ -158,7 +158,12 @@ gst_pipewire_stream_close (GstPipeWireStream * self) /* destroy the pw stream */ pw_thread_loop_lock (self->core->loop); - g_clear_pointer (&self->pwstream, pw_stream_destroy); + if (self->pwstream) { + /* Do not use g_clear_pointer() here as pw_stream_destroy() may chain up to + * code requiring the pointer to still be around */ + pw_stream_destroy (self->pwstream); + self->pwstream = NULL; + } pw_thread_loop_unlock (self->core->loop); /* release the core */