caps: Fix null pointer dereference on invalid static caps
authorJan Schmidt <jan@centricular.com>
Mon, 2 Jan 2017 15:11:27 +0000 (02:11 +1100)
committerJan Schmidt <jan@centricular.com>
Mon, 2 Jan 2017 15:21:10 +0000 (02:21 +1100)
A typo in a static caps string may result in failure to
deserialise it, so don't dereference the result without
checking.

gst/gstcaps.c

index 7c68129..c947f37 100644 (file)
@@ -423,12 +423,14 @@ gst_static_caps_get (GstStaticCaps * static_caps)
 
     *caps = gst_caps_from_string (string);
 
-    /* Caps generated from static caps are usually leaked */
-    GST_MINI_OBJECT_FLAG_SET (*caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
-
     /* convert to string */
-    if (G_UNLIKELY (*caps == NULL))
+    if (G_UNLIKELY (*caps == NULL)) {
       g_critical ("Could not convert static caps \"%s\"", string);
+      goto done;
+    }
+
+    /* Caps generated from static caps are usually leaked */
+    GST_MINI_OBJECT_FLAG_SET (*caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
 
     GST_CAT_TRACE (GST_CAT_CAPS, "created %p from string %s", static_caps,
         string);