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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1220>
This commit is contained in:
James Cowgill 2021-10-20 12:08:49 +01:00 committed by GStreamer Marge Bot
parent 1aab0e49f6
commit 3846b0563a

View file

@ -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);