[vlc-devel] commit: Do not insert a module in the list twice ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Jan 27 18:25:23 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jan 27 19:22:46 2010 +0200| [e9d39acf422ca83a6d9c10654ce841ab0a8c9e7e] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e9d39acf422ca83a6d9c10654ce841ab0a8c9e7e
---

 src/modules/modules.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/modules/modules.c b/src/modules/modules.c
index 142e88a..0af81ac 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -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;




More information about the vlc-devel mailing list