From: Víctor Manuel Jáquez Leal Date: Sun, 30 Jan 2022 06:10:09 +0000 (+0100) Subject: vaapi: libs: video-format: Check if formats map is not NULL. X-Git-Tag: 1.20.0~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fc4e928d6b0440f666f901b6ebef43b9199d9e0;p=platform%2Fupstream%2Fgstreamer.git vaapi: libs: video-format: Check if formats map is not NULL. Formats map is instantiated at the end of the display instantiation. The problem is the Wayland display which looks for a format in a callback, before the map is populated. If user compiles gstreamer-vaapi with DRM support, the map is populated with a DRM display at GStreamer plugin registration. But if not, or a VA driver is not available, the plugin will try with a Wayland driver, which cause the NULL de-reference. Nevertheless, in the case of no DRM support, and if the Wayland display doesn't get a reply from the format conversion is not a problem. So the solution is the trivial one, check if the format map is already populated before de-reference it. Fixes: #977 Part-of: --- diff --git a/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/video-format.c b/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/video-format.c index dad7570c2e..5fd35e3d6e 100644 --- a/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/video-format.c +++ b/subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/video-format.c @@ -185,7 +185,7 @@ static const GstVideoFormatMap gst_vaapi_video_default_formats[] = { #undef DEF_RGB #undef DEF_YUV -static GArray *gst_vaapi_video_formats_map; +static GArray *gst_vaapi_video_formats_map = NULL; static inline gboolean va_format_is_rgb (const VAImageFormat * va_format) @@ -254,6 +254,9 @@ get_map_by_gst_format (const GArray * formats, GstVideoFormat format) const GstVideoFormatMap *entry; guint i; + if (!formats) + return NULL; + for (i = 0; i < formats->len; i++) { entry = &g_array_index (formats, GstVideoFormatMap, i); if (entry->format == format) @@ -269,6 +272,9 @@ get_map_by_va_format (const VAImageFormat * va_format) const GstVideoFormatMap *entry; guint i; + if (!formats) + return NULL; + for (i = 0; i < formats->len; i++) { entry = &g_array_index (formats, GstVideoFormatMap, i); if (va_format_is_same (&entry->va_format, va_format)) @@ -642,6 +648,9 @@ gst_vaapi_drm_format_from_va_fourcc (guint32 fourcc) const GstVideoFormatMap *m; guint i; + if (!map) + return GST_VIDEO_FORMAT_UNKNOWN; + /* Note: VA fourcc values are now standardized and shall represent a unique format. The associated VAImageFormat is just a hint to determine RGBA component ordering */ @@ -675,6 +684,9 @@ gst_vaapi_video_format_from_drm_format (guint drm_format) const GstVideoFormatMap *m; guint i; + if (!map) + return GST_VIDEO_FORMAT_UNKNOWN; + for (i = 0; i < map->len; i++) { m = &g_array_index (map, GstVideoFormatMap, i); if (m->drm_format == drm_format)