diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2010-05-24 21:11:17 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2010-05-24 21:11:17 +0200 |
commit | aaf753e2ff010aecb29f53b21bce12eb26ebde5e (patch) | |
tree | 43966c034bacfc7f111aed29a5270c3089b0de87 /src | |
parent | 785995d2592d8ea27170b225ae9e55af334c4bf4 (diff) | |
download | wolfbones-aaf753e2ff010aecb29f53b21bce12eb26ebde5e.tar.gz wolfbones-aaf753e2ff010aecb29f53b21bce12eb26ebde5e.tar.bz2 |
fixed wrong handling of dlsym
Diffstat (limited to 'src')
-rw-r--r-- | src/library/loader.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/library/loader.c b/src/library/loader.c index 1606557..8419445 100644 --- a/src/library/loader.c +++ b/src/library/loader.c @@ -132,11 +132,18 @@ char *wolf_library_error_msg( const wolf_library_p library, char *buf, size_t b WOLF_LIBRARY_FUNCPTR wolf_library_get_func( const wolf_library_p l, const char *name, wolf_error_t *error ) { WOLF_LIBRARY_FUNCPTR ret; + char *err = NULL; #if defined HAVE_DLFCN + /* clear error state before calling dlsym, so that calling dlsym + * can return a NULL as value of a symbol + */ + (void)dlerror( ); + ret = dlsym( l->handle, name ); - if( ret == NULL ) { - strncpy( l->errbuf, dlerror( ), INTERNAL_ERRBUF_SIZE ); + err = dlerror( ); + if( err != NULL ) { + strncpy( l->errbuf, err, INTERNAL_ERRBUF_SIZE ); *error = WOLF_ERR_INTERNAL; return ret; } |