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

Do not insert a module in the list twice

If the same module (i.e. currently same file path) is scanned more than
once, the linked list would get corrupted, and VLC crash while loading.

This could happen, e.g. if you put $(vlclibdir) into --plugin-path.
parent 98ab5ed7
...@@ -939,6 +939,10 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -939,6 +939,10 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
p_module = p_cache_entry->p_module; p_module = p_cache_entry->p_module;
p_module->b_loaded = false; p_module->b_loaded = false;
/* If plugin-path contains duplicate entries... */
if( p_module->next != NULL )
return 0; /* already taken care of that one */
/* For now we force loading if the module's config contains /* For now we force loading if the module's config contains
* callbacks or actions. * callbacks or actions.
* Could be optimized by adding an API call.*/ * Could be optimized by adding an API call.*/
...@@ -956,6 +960,9 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -956,6 +960,9 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
if( p_module == NULL ) if( p_module == NULL )
return -1; return -1;
/* We have not already scanned and inserted this module */
assert( p_module->next == NULL );
/* Everything worked fine ! /* Everything worked fine !
* The module is ready to be added to the list. */ * The module is ready to be added to the list. */
p_module->b_builtin = false; p_module->b_builtin = false;
...@@ -964,6 +971,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank, ...@@ -964,6 +971,7 @@ static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
p_module->psz_object_name, p_module->psz_longname ); */ p_module->psz_object_name, p_module->psz_longname ); */
p_module->next = p_bank->head; p_module->next = p_bank->head;
p_bank->head = p_module; p_bank->head = p_module;
assert( p_module->next != NULL ); /* Insertion done */
if( !p_module_bank->b_cache ) if( !p_module_bank->b_cache )
return 0; return 0;
......
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