From a734f9579064c8aa3acf32f4daa45428f9a9bb5e Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 23 Feb 2024 21:54:17 +0800 Subject: [PATCH] vabasedec: Fix a possible NULL pointer dereference The format in _get_preferred_format_and_caps_features() may be NULL. Part-of: --- subprojects/gst-plugins-bad/sys/va/gstvabasedec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c index 72c98415de..736163e7f2 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasedec.c @@ -876,10 +876,13 @@ gst_va_base_dec_get_preferred_format_and_caps_features (GstVaBaseDec * base, * if downstream doesn't support system memory negotiation will fail later. */ if (is_any) { + GstVideoFormat fmt = + _caps_video_format_from_chroma (allowed_caps, base->rt_format); features = GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY; + if (format) - *format = _caps_video_format_from_chroma (allowed_caps, base->rt_format); - if (capsfeatures && *format != GST_VIDEO_FORMAT_UNKNOWN) + *format = fmt; + if (capsfeatures && fmt != GST_VIDEO_FORMAT_UNKNOWN) *capsfeatures = gst_caps_features_copy (features); goto bail; }