video-color: Deal with NULL colorimetry while converting from string
authorArun Raghavan <arun@arunraghavan.net>
Fri, 24 May 2019 13:22:58 +0000 (15:22 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 11 Aug 2019 11:56:08 +0000 (12:56 +0100)
This came up in the case where v4l2 sets caps with colorimetry=NULL, and
then tries to parse back the colorimetry, causing a crash in
gst_video_get_colorimetry() because of g_str_equal(). We fix this by
making sure the only caller of the function never calls it with a null
colorimetry string.

gst-libs/gst/video/video-color.c

index ec3dddc..04d8aeb 100644 (file)
@@ -119,7 +119,10 @@ gst_video_colorimetry_from_string (GstVideoColorimetry * cinfo,
   const ColorimetryInfo *ci;
   gboolean res = FALSE;
 
-  if ((ci = gst_video_get_colorimetry (color))) {
+  if (!color) {
+    *cinfo = colorimetry[DEFAULT_UNKNOWN].color;
+    res = TRUE;
+  } else if ((ci = gst_video_get_colorimetry (color))) {
     *cinfo = ci->color;
     res = TRUE;
   } else {