X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fplugins.c;h=3cc156dcca33a96b0c04f590cc038b8451068b8b;hb=abcabca628baf7989fde32b378c8d4783e6346df;hp=2c5cf9524cc5044bbe310c28067d3e659a1aac44;hpb=50118171a93a426f2f553369aa65bbc42101d8b8;p=vlc diff --git a/src/misc/plugins.c b/src/misc/plugins.c index 2c5cf9524c..3cc156dcca 100644 --- a/src/misc/plugins.c +++ b/src/misc/plugins.c @@ -27,6 +27,10 @@ #include /* sprintf() */ #include /* strerror() */ #include /* ENOMEM */ +#include /* open */ +#include +#include +#include /* close */ #if defined(HAVE_DLFCN_H) /* Linux, BSD, Hurd */ #include /* dlopen(), dlsym(), dlclose() */ @@ -135,7 +139,7 @@ void bank_Destroy( plugin_bank_t * p_bank ) char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name ) { - int i_count, i_length; + int i_count, i_length, i_fd; char * psz_plugin; char * psz_plugin_path[ ] = { @@ -163,6 +167,15 @@ char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name ) psz_plugin = malloc( strlen(psz_plugin_path[i_count]) + i_length + 5 ); sprintf( psz_plugin, "%s/%s.so", psz_plugin_path[i_count], psz_name ); + /* Try to open the plugin before dlopen()ing it. */ + i_fd = open( psz_plugin, O_RDONLY ); + if( i_fd == -1 ) + { + free( psz_plugin ); + continue; + } + close( i_fd ); + *p_plugin_id = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL ); #endif @@ -175,11 +188,9 @@ char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name ) /* plugin successfuly dlopened */ return( psz_plugin ); } + #ifndef SYS_BEOS - else - { - intf_WarnMsg( 1, "dlerror: %s\n", dlerror() ); - } + intf_WarnMsg( 1, "Plugin %s failed: %s\n", psz_plugin, dlerror() ); #endif free( psz_plugin );