[vlc-commits] Destroy submodules from vlc_module_destroy()
Rémi Denis-Courmont
git at videolan.org
Tue Aug 16 18:20:56 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 16 10:56:32 2011 +0300| [eccbdf8f91c9917c97782ad937ffd3f1fcbb642b] | committer: Rémi Denis-Courmont
Destroy submodules from vlc_module_destroy()
Again, this should help fix leaks in error paths.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=eccbdf8f91c9917c97782ad937ffd3f1fcbb642b
---
src/modules/entry.c | 8 ++++++++
src/modules/modules.c | 10 +---------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/modules/entry.c b/src/modules/entry.c
index ba5aa75..14e366f 100644
--- a/src/modules/entry.c
+++ b/src/modules/entry.c
@@ -73,6 +73,14 @@ module_t *vlc_module_create (void)
void vlc_module_destroy (module_t *module)
{
+ for (module_t *m = module->submodule, *next; m != NULL; m = next)
+ {
+ next = m->next;
+ vlc_module_destroy (m);
+ }
+
+ free (module->domain);
+ free (module->psz_filename);
for (unsigned i = 0; i < module->i_shortcuts; i++)
free (module->pp_shortcuts[i]);
free (module->pp_shortcuts);
diff --git a/src/modules/modules.c b/src/modules/modules.c
index e654dd8..e261f13 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -1050,6 +1050,7 @@ static module_t *module_InitStatic (vlc_plugin_cb entry)
static void DeleteModule (module_t **head, module_t *p_module)
{
assert( p_module );
+ assert (p_module->parent == NULL);
/* Unlist the module (if it is in the list) */
module_t **pp_self = head;
@@ -1062,17 +1063,8 @@ static void DeleteModule (module_t **head, module_t *p_module)
#ifdef HAVE_DYNAMIC_PLUGINS
if (p_module->b_loaded && p_module->b_unloadable)
module_Unload (p_module->handle);
- free (p_module->psz_filename);
#endif
- /* Free and detach the object's children */
- while (p_module->submodule)
- {
- module_t *submodule = p_module->submodule;
- p_module->submodule = submodule->next;
- vlc_module_destroy (submodule);
- }
-
config_Free( p_module );
vlc_module_destroy (p_module);
}
More information about the vlc-commits
mailing list