From 944de3aa68b2722586c0186a333fc370e0188a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 2 Jul 2008 14:43:40 +0000 Subject: [PATCH] gst/gstplugin.c: Print error debug message if plugin description fields that should be set are NULL. Original commit message from CVS: * gst/gstplugin.c: (CHECK_PLUGIN_DESC_FIELD), (gst_plugin_load_file): Print error debug message if plugin description fields that should be set are NULL. * gst/gstregistrybinary.c: (gst_registry_binary_save_const_string): Don't crash if the string to serialise is NULL (it really should not be, but apparently this used to work with the xml registry ...). --- ChangeLog | 10 ++++++++++ gst/gstplugin.c | 15 +++++++++++++++ gst/gstregistrybinary.c | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/ChangeLog b/ChangeLog index 61fb70d4fe..9f212a7b92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-07-02 Tim-Philipp Müller + + * gst/gstplugin.c: (CHECK_PLUGIN_DESC_FIELD), (gst_plugin_load_file): + Print error debug message if plugin description fields that should + be set are NULL. + + * gst/gstregistrybinary.c: (gst_registry_binary_save_const_string): + Don't crash if the string to serialise is NULL (it really should + not be, but apparently this used to work with the xml registry ...). + 2008-07-02 Thijs Vermeir * tools/gst-plot-timeline.py: diff --git a/gst/gstplugin.c b/gst/gstplugin.c index fa55cc7c4f..63ab0e8700 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -430,6 +430,11 @@ static void _gst_plugin_fault_handler_setup (); static GStaticMutex gst_plugin_loading_mutex = G_STATIC_MUTEX_INIT; +#define CHECK_PLUGIN_DESC_FIELD(desc,field,fn) \ + if (G_UNLIKELY ((desc)->field == NULL)) { \ + GST_ERROR ("GstPluginDesc for '%s' has no %s", fn, G_STRINGIFY (field)); \ + } + /** * gst_plugin_load_file: * @filename: the plugin filename to load @@ -520,6 +525,16 @@ gst_plugin_load_file (const gchar * filename, GError ** error) } plugin->orig_desc = (GstPluginDesc *) ptr; + /* check plugin description: complain about bad values but accept them, to + * maintain backwards compatibility (FIXME: 0.11) */ + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, name, filename); + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, description, filename); + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, version, filename); + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, license, filename); + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, source, filename); + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, package, filename); + CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, origin, filename); + GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...", plugin, filename); diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index a9cc3e0a49..8635ac651d 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -291,6 +291,11 @@ gst_registry_binary_save_const_string (GList ** list, const gchar * str) { GstBinaryChunk *chunk; + if (G_UNLIKELY (str == NULL)) { + GST_ERROR ("unexpected NULL string in plugin or plugin feature data"); + str = ""; + } + chunk = g_malloc (sizeof (GstBinaryChunk)); chunk->data = (gpointer) str; chunk->size = strlen ((gchar *) chunk->data) + 1;