From c527fd8dad17bf34dd2b9a809f977acae138115a Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Fri, 8 Jul 2005 16:08:16 +0000 Subject: [PATCH] plug another memleak in registry loading - I have NO idea why this was returning a GstPlugin Original commit message from CVS: plug another memleak in registry loading - I have NO idea why this was returning a GstPlugin --- ChangeLog | 6 ++++++ gst/registries/gstlibxmlregistry.c | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28d50e5520..940c17e605 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-07-08 Thomas Vander Stichele + + * gst/registries/gstlibxmlregistry.c: (read_string), (load_paths), + (gst_xml_registry_load): + plug another memleak + 2005-07-08 Thomas Vander Stichele * configure.ac: diff --git a/gst/registries/gstlibxmlregistry.c b/gst/registries/gstlibxmlregistry.c index f6dfd567da..9a4d5f2a11 100644 --- a/gst/registries/gstlibxmlregistry.c +++ b/gst/registries/gstlibxmlregistry.c @@ -573,6 +573,11 @@ add_to_char_array (gchar *** array, gchar * value) *array = new; } +/* read a string and store the result in *write_to. + * return whether or not *write_to was set to a newly allocated string + * FIXME: return values aren't actually checked, and in those failure cases + * (that currently aren't triggered) cleanup is not done correctly + */ static gboolean read_string (xmlTextReaderPtr reader, gchar ** write_to) { @@ -585,12 +590,14 @@ read_string (xmlTextReaderPtr reader, gchar ** write_to) if (xmlTextReaderDepth (reader) == depth) return found; if (xmlTextReaderNodeType (reader) == XML_READER_TYPE_TEXT) { - if (found) + if (found) { return FALSE; + } *write_to = g_strdup ((gchar *) xmlTextReaderConstValue (reader)); found = TRUE; } } + return FALSE; } @@ -850,15 +857,14 @@ load_plugin (xmlTextReaderPtr reader) return NULL; } -static GstPlugin * +static void load_paths (xmlTextReaderPtr reader, GstXMLRegistry * registry) { int ret; - GstPlugin *plugin = g_new0 (GstPlugin, 1); while ((ret = xmlTextReaderRead (reader)) == 1) { if (xmlTextReaderDepth (reader) == 1) { - return plugin; + return; } if (xmlTextReaderNodeType (reader) == XML_READER_TYPE_ELEMENT && xmlTextReaderDepth (reader) == 2) { @@ -876,8 +882,7 @@ load_paths (xmlTextReaderPtr reader, GstXMLRegistry * registry) } } - g_free (plugin); - return NULL; + return; } static gboolean @@ -925,7 +930,8 @@ gst_xml_registry_load (GstRegistry * registry) GstPlugin *plugin = load_plugin (reader); if (plugin) { - GST_DEBUG ("adding plugin %s with %d features", plugin->desc.name, + GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, + "adding plugin %s with %d features", plugin->desc.name, plugin->numfeatures); gst_registry_add_plugin (GST_REGISTRY (xmlregistry), plugin); }