openjpegdec: Don't crash if colorspace is not provided on the caps
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 18 Dec 2012 14:43:37 +0000 (15:43 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 18 Dec 2012 14:43:37 +0000 (15:43 +0100)
g_str_equal() is *not* NULL-safe

ext/openjpeg/gstopenjpegdec.c

index 33fdf1d..d027e96 100644 (file)
@@ -171,13 +171,14 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
     g_return_val_if_reached (FALSE);
   }
 
-  color_space = gst_structure_get_string (s, "colorspace");
-  if (g_str_equal (color_space, "sRGB"))
-    self->color_space = CLRSPC_SRGB;
-  else if (g_str_equal (color_space, "GRAY"))
-    self->color_space = CLRSPC_GRAY;
-  else if (g_str_equal (color_space, "sYUV"))
-    self->color_space = CLRSPC_SYCC;
+  if ((color_space = gst_structure_get_string (s, "colorspace"))) {
+    if (g_str_equal (color_space, "sRGB"))
+      self->color_space = CLRSPC_SRGB;
+    else if (g_str_equal (color_space, "GRAY"))
+      self->color_space = CLRSPC_GRAY;
+    else if (g_str_equal (color_space, "sYUV"))
+      self->color_space = CLRSPC_SYCC;
+  }
 
   self->ncomps = 0;
   gst_structure_get_int (s, "num-components", &self->ncomps);