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)
committerArun Raghavan <arun@arunraghavan.net>
Fri, 24 May 2019 14:37:14 +0000 (16:37 +0200)
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 08ba8e3..e49a412 100644 (file)
@@ -118,7 +118,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 {