Commit eccbdf8f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Destroy submodules from vlc_module_destroy()

Again, this should help fix leaks in error paths.
parent cefb8d38
...@@ -73,6 +73,14 @@ module_t *vlc_module_create (void) ...@@ -73,6 +73,14 @@ module_t *vlc_module_create (void)
void vlc_module_destroy (module_t *module) 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++) for (unsigned i = 0; i < module->i_shortcuts; i++)
free (module->pp_shortcuts[i]); free (module->pp_shortcuts[i]);
free (module->pp_shortcuts); free (module->pp_shortcuts);
......
...@@ -1050,6 +1050,7 @@ static module_t *module_InitStatic (vlc_plugin_cb entry) ...@@ -1050,6 +1050,7 @@ static module_t *module_InitStatic (vlc_plugin_cb entry)
static void DeleteModule (module_t **head, module_t *p_module) static void DeleteModule (module_t **head, module_t *p_module)
{ {
assert( p_module ); assert( p_module );
assert (p_module->parent == NULL);
/* Unlist the module (if it is in the list) */ /* Unlist the module (if it is in the list) */
module_t **pp_self = head; module_t **pp_self = head;
...@@ -1062,17 +1063,8 @@ static void DeleteModule (module_t **head, module_t *p_module) ...@@ -1062,17 +1063,8 @@ static void DeleteModule (module_t **head, module_t *p_module)
#ifdef HAVE_DYNAMIC_PLUGINS #ifdef HAVE_DYNAMIC_PLUGINS
if (p_module->b_loaded && p_module->b_unloadable) if (p_module->b_loaded && p_module->b_unloadable)
module_Unload (p_module->handle); module_Unload (p_module->handle);
free (p_module->psz_filename);
#endif #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 ); config_Free( p_module );
vlc_module_destroy (p_module); vlc_module_destroy (p_module);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment