From 3846b0563af1ae40c2e38a205fbef43c01d706f6 Mon Sep 17 00:00:00 2001 From: James Cowgill Date: Wed, 20 Oct 2021 12:08:49 +0100 Subject: [PATCH] v4l2codecs: Fix segfault when destroying non-detached allocator The GstV4l2CodecAllocator dispose function clears `self->decoder` but the finalize function then tries to use it if the allocator has no been detached yet. Fix by detaching in the dispose function before we clear `self->decoder`. Part-of: --- .../sys/v4l2codecs/gstv4l2codecallocator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecallocator.c b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecallocator.c index e2886989cc..40238bdafe 100644 --- a/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecallocator.c +++ b/subprojects/gst-plugins-bad/sys/v4l2codecs/gstv4l2codecallocator.c @@ -213,7 +213,10 @@ gst_v4l2_codec_allocator_dispose (GObject * object) while ((buf = g_queue_pop_head (&self->pool))) gst_v4l2_codec_buffer_free (buf); - gst_clear_object (&self->decoder); + if (self->decoder) { + gst_v4l2_codec_allocator_detach (self); + gst_clear_object (&self->decoder); + } G_OBJECT_CLASS (gst_v4l2_codec_allocator_parent_class)->dispose (object); } @@ -223,9 +226,6 @@ gst_v4l2_codec_allocator_finalize (GObject * object) { GstV4l2CodecAllocator *self = GST_V4L2_CODEC_ALLOCATOR (object); - if (!self->detached) - gst_v4l2_decoder_request_buffers (self->decoder, self->direction, 0); - g_cond_clear (&self->buffer_cond); G_OBJECT_CLASS (gst_v4l2_codec_allocator_parent_class)->finalize (object);