summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-03-27 18:53:10 -0700
committerEric Anholt <eric@anholt.net>2014-03-27 23:17:02 -0700
commit72187a29c2d1e4852dfcb9b397418ff21dae1835 (patch)
tree75e305610d0cc510cd937f8356562c904417e0a0
parente230042ffe3f55c24153d908c8aa0c255e1b3620 (diff)
downloadlibepoxy-72187a29c2d1e4852dfcb9b397418ff21dae1835.tar.gz
Don't dlsym() if we failed to dlopen().
No reported bugs I'm fixing here, just cleanup.
-rw-r--r--src/dispatch_common.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index bc2b827..c3c9245 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -167,11 +167,11 @@ library_init(void)
library_initialized = true;
}
-static void
+static bool
get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail)
{
if (*handle)
- return;
+ return true;
if (!library_initialized) {
fprintf(stderr,
@@ -192,6 +192,8 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail)
}
pthread_mutex_unlock(&api.mutex);
#endif
+
+ return *handle != NULL;
}
static void *
@@ -200,7 +202,8 @@ do_dlsym(void **handle, const char *lib_name, const char *name,
{
void *result;
- get_dlopen_handle(handle, lib_name, exit_on_fail);
+ if (!get_dlopen_handle(handle, lib_name, exit_on_fail))
+ return NULL;
#ifdef _WIN32
result = GetProcAddress(*handle, name);