From 30ddb0cd97c91dba5d6192e53debac280335efff Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Sun, 6 Mar 2022 19:18:20 +0900 Subject: [PATCH] nvcodec: Add missing null check in context sharing code Part-of: --- .../gst-plugins-bad/sys/nvcodec/gstcudautils.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c index 63e0357050..4fb8312cdf 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudautils.c @@ -102,18 +102,22 @@ find_cuda_context (GstElement * element, GstCudaContext ** cuda_ctx) query = gst_query_new_context (GST_CUDA_CONTEXT_TYPE); if (run_query (element, query, GST_PAD_SRC)) { gst_query_parse_context (query, &ctxt); - GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, - "found context (%p) in downstream query", ctxt); - gst_element_set_context (element, ctxt); + if (ctxt) { + GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, + "found context (%p) in downstream query", ctxt); + gst_element_set_context (element, ctxt); + } } /* although we found cuda context above, the element does not want * to use the context. Then try to find from the other direction */ if (*cuda_ctx == NULL && run_query (element, query, GST_PAD_SINK)) { gst_query_parse_context (query, &ctxt); - GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, - "found context (%p) in upstream query", ctxt); - gst_element_set_context (element, ctxt); + if (ctxt) { + GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, + "found context (%p) in upstream query", ctxt); + gst_element_set_context (element, ctxt); + } } if (*cuda_ctx == NULL) {