caps: don't create broken caps for invalid media types

Check if structure has been created before appending it to the caps. Free the
caps in the case of an error to not conceal it be returning empty caps.

Fixes #642271
This commit is contained in:
Jonathan Matthew 2011-03-04 08:28:25 +10:00 committed by Stefan Kost
parent eb05020f58
commit 2bbfa3304c

View file

@ -225,7 +225,10 @@ gst_caps_new_simple (const char *media_type, const char *fieldname, ...)
structure = gst_structure_new_valist (media_type, fieldname, var_args);
va_end (var_args);
gst_caps_append_structure_unchecked (caps, structure);
if (structure)
gst_caps_append_structure_unchecked (caps, structure);
else
gst_caps_replace (&caps, NULL);
return caps;
}