From c87f9eb37bd18bb1ec0a44fef0c2e17bbdd7663f Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 9 Jul 2018 13:59:02 -0400 Subject: [PATCH] v4l2videodec: Protect double calls to set_format() In some cases, set_format() may get called twice before the output format is set. Running an allocation query in this case is both not needed and will cause assertion due tot he NULL caps. --- sys/v4l2/gstv4l2videodec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c index a00ccd9..838ebff 100644 --- a/sys/v4l2/gstv4l2videodec.c +++ b/sys/v4l2/gstv4l2videodec.c @@ -260,10 +260,12 @@ gst_v4l2_video_dec_set_format (GstVideoDecoder * decoder, * block. */ { GstCaps *caps = gst_pad_get_current_caps (decoder->srcpad); - GstQuery *query = gst_query_new_allocation (caps, FALSE); - gst_pad_peer_query (decoder->srcpad, query); - gst_query_unref (query); - gst_caps_unref (caps); + if (caps) { + GstQuery *query = gst_query_new_allocation (caps, FALSE); + gst_pad_peer_query (decoder->srcpad, query); + gst_query_unref (query); + gst_caps_unref (caps); + } } gst_v4l2_object_stop (self->v4l2capture); -- 2.7.4