]> git.sesse.net Git - vlc/commitdiff
Do not insert a module in the list twice
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 27 Jan 2010 17:22:46 +0000 (19:22 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 27 Jan 2010 17:25:14 +0000 (19:25 +0200)
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.

src/modules/modules.c

index 142e88a7dd530f0acb5243d89c54359d1ab68edc..0af81ac97baa7a118973125c6dc931d5172a3750 100644 (file)
@@ -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->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
          * callbacks or actions.
          * 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,
     if( p_module == NULL )
         return -1;
 
+    /* We have not already scanned and inserted this module */
+    assert( p_module->next == NULL );
+
     /* Everything worked fine !
      * The module is ready to be added to the list. */
     p_module->b_builtin = false;
@@ -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->next = p_bank->head;
     p_bank->head = p_module;
+    assert( p_module->next != NULL ); /* Insertion done */
 
     if( !p_module_bank->b_cache )
         return 0;