From 51b83d5ca184196bb48d494658680d007b6ee1d7 Mon Sep 17 00:00:00 2001 From: James Cowgill Date: Tue, 29 Oct 2019 14:05:48 +0000 Subject: [PATCH] v4l2videodec: ensure pool exists before orphaning it In commit e2ff87732d0b ("v4l2videodec: support orphaning") support for orphaning the capture buffer pool was added when the format is renegotiated. However, the commit forgot to check that a pool existed before doing this. This is needed because it's possible for the format to be renegotiated before a capture pool is allocated, which would result in trying to orphan a NULL pool and lead to a NULL pointer dereference. Fix this by checking a pool exists first. If the pool doesn't exist, there are no buffers to be reclaimed, so skip the allocation query in that case. --- sys/v4l2/gstv4l2videodec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c index a22a0ad8f4..39b4fd19a8 100644 --- a/sys/v4l2/gstv4l2videodec.c +++ b/sys/v4l2/gstv4l2videodec.c @@ -254,7 +254,8 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder, * the complexity and should not have much impact in performance since the * following allocation query will happen on a drained pipeline and won't * block. */ - if (!gst_v4l2_buffer_pool_orphan (&self->v4l2capture->pool)) { + if (self->v4l2capture->pool && + !gst_v4l2_buffer_pool_orphan (&self->v4l2capture->pool)) { GstCaps *caps = gst_pad_get_current_caps (decoder->srcpad); if (caps) { GstQuery *query = gst_query_new_allocation (caps, FALSE);