summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2005-09-07 14:56:17 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2005-09-07 14:56:17 +0000
commitc17a476bc8d29fed920ad0ff0ea02bc83b319081 (patch)
treed9cd15ae1108f34a0426d48fc37e2f48870a301f
parent37a9e675d473d4604d41c024821bbd0bdb3d8f01 (diff)
downloadgstreamer-c17a476bc8d29fed920ad0ff0ea02bc83b319081.tar.gz
gst/: Always call g_module_close on error so the symbols don't hang around.
Original commit message from CVS: * gst/gstplugin.c: (gst_plugin_check_file), (gst_plugin_load_file), (gst_plugin_free): * gst/gstplugin.h: * gst/gstregistry.c: (gst_registry_add_plugin): Always call g_module_close on error so the symbols don't hang around. Plug a leak or two, I think.
-rw-r--r--ChangeLog10
m---------common0
-rw-r--r--gst/gstplugin.c36
-rw-r--r--gst/gstplugin.h1
-rw-r--r--gst/gstregistry.c2
5 files changed, 45 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e979792ffa..3b8823487e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-09-07 Jan Schmidt <thaytan@mad.scientist.com>
+
+ * gst/gstplugin.c: (gst_plugin_check_file), (gst_plugin_load_file),
+ (gst_plugin_free):
+ * gst/gstplugin.h:
+ * gst/gstregistry.c: (gst_registry_add_plugin):
+ Always call g_module_close on error so the symbols don't hang
+ around.
+ Plug a leak or two, I think.
+
2005-09-04 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:
diff --git a/common b/common
-Subproject 54886902497be267fe1f1a3f9c4dc0245bc4617
+Subproject 00cc4f5af95a15be55b8c1b3eed09f4738412f9
diff --git a/gst/gstplugin.c b/gst/gstplugin.c
index fc6d6d8ddb..bc373abc50 100644
--- a/gst/gstplugin.c
+++ b/gst/gstplugin.c
@@ -376,7 +376,8 @@ gst_plugin_check_file (const gchar * filename, GError ** error)
module = g_module_open (filename, G_MODULE_BIND_LAZY);
check = gst_plugin_check_module (module, filename, error, NULL);
- g_module_close (module);
+ if (module != NULL)
+ g_module_close (module);
GST_INFO ("file \"%s\" %s look like a gst plugin", filename,
check ? "does" : "doesn't");
@@ -409,8 +410,11 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
module = g_module_open (filename, G_MODULE_BIND_LAZY);
- if (!gst_plugin_check_module (module, filename, error, &ptr)) /* handles module == NULL case */
+ if (!gst_plugin_check_module (module, filename, error, &ptr)) { /* handles module == NULL case */
+ if (module != NULL)
+ g_module_close (module);
return NULL;
+ }
desc = (GstPluginDesc *) ptr;
@@ -435,7 +439,7 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
"loaded, aborting loading of \"%s\"", plugin, plugin->filename,
plugin->desc.name, filename);
if (free_plugin)
- g_free (plugin);
+ gst_plugin_free (plugin);
return NULL;
}
GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now",
@@ -478,7 +482,7 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
"gst_plugin_register_func failed for plugin \"%s\"", filename);
g_module_close (module);
if (free_plugin)
- g_free (plugin);
+ gst_plugin_free (plugin);
return NULL;
}
}
@@ -921,3 +925,27 @@ gst_library_load (const gchar * name)
return res;
}
+
+/**
+ * gst_plugin_free:
+ * @plugin: Plugin structure to clean up and free.
+ *
+ * Frees the memory associated with a plugin
+ */
+void
+gst_plugin_free (GstPlugin * plugin)
+{
+ g_return_if_fail (plugin != NULL);
+
+ g_free (plugin->filename);
+
+ if (plugin->module)
+ g_module_close (plugin->module);
+
+ /* anything to clean up in these?
+ * GstPluginDesc desc
+ * GList * features;
+ */
+
+ g_free (plugin);
+}
diff --git a/gst/gstplugin.h b/gst/gstplugin.h
index 13602d099c..0abd250c39 100644
--- a/gst/gstplugin.h
+++ b/gst/gstplugin.h
@@ -126,6 +126,7 @@ typedef gboolean (*GstPluginFilter) (GstPlugin *plugin,
GType gst_plugin_get_type (void);
void _gst_plugin_initialize (void);
void _gst_plugin_register_static (GstPluginDesc *desc);
+void gst_plugin_free (GstPlugin *plugin);
G_CONST_RETURN gchar* gst_plugin_get_name (GstPlugin *plugin);
G_CONST_RETURN gchar* gst_plugin_get_description (GstPlugin *plugin);
diff --git a/gst/gstregistry.c b/gst/gstregistry.c
index 44352fbaec..e9e91beba5 100644
--- a/gst/gstregistry.c
+++ b/gst/gstregistry.c
@@ -282,10 +282,12 @@ gboolean
gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
{
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
+ g_return_val_if_fail (plugin != NULL, FALSE);
if (gst_registry_pool_find_plugin (gst_plugin_get_name (plugin))) {
GST_WARNING_OBJECT (registry, "Not adding plugin %s, "
"because a plugin with same name already exists",
gst_plugin_get_name (plugin));
+ gst_plugin_free (plugin);
return FALSE;
}