mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 09:41:07 +00:00
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.
This commit is contained in:
parent
37a9e675d4
commit
c17a476bc8
5 changed files with 46 additions and 5 deletions
10
ChangeLog
10
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:
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 54886902497be267fe1f1a3f9c4dc0245bc46175
|
||||
Subproject commit 00cc4f5af95a15be55b8c1b3eed09f4738412f91
|
|
@ -376,6 +376,7 @@ 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);
|
||||
if (module != NULL)
|
||||
g_module_close (module);
|
||||
|
||||
GST_INFO ("file \"%s\" %s look like a gst plugin", filename,
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue