From 67e9f15944f7662a17eb0ac76159ed9134d93505 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 3 Jan 2017 02:11:27 +1100 Subject: [PATCH] caps: Fix null pointer dereference on invalid static caps 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 7c6812951b..c947f372a7 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -423,13 +423,15 @@ gst_static_caps_get (GstStaticCaps * static_caps) *caps = gst_caps_from_string (string); + /* convert to string */ + 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); - /* convert to string */ - if (G_UNLIKELY (*caps == NULL)) - g_critical ("Could not convert static caps \"%s\"", string); - GST_CAT_TRACE (GST_CAT_CAPS, "created %p from string %s", static_caps, string); done: