From: RĂ©mi Denis-Courmont Date: Wed, 27 Jan 2010 17:22:46 +0000 (+0200) Subject: Do not insert a module in the list twice X-Git-Tag: 1.1.0-ff~822 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=e9d39acf422ca83a6d9c10654ce841ab0a8c9e7e;p=vlc 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. --- diff --git a/src/modules/modules.c b/src/modules/modules.c index 142e88a7dd..0af81ac97b 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;