1 diff --git a/src/dispatch_common.c b/src/dispatch_common.c
2 index b3e4f5f..303e8f5 100644
3 --- a/src/dispatch_common.c
4 +++ b/src/dispatch_common.c
5 @@ -310,6 +310,19 @@ get_dlopen_handle(void **handle, const char *lib_name, bool exit_on_fail, bool l
8 *handle = dlopen(lib_name, flags);
11 + char pathbuf[sizeof(LIBGL_PATH) + 1 + 1024 + 1];
12 + int l = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", LIBGL_PATH, lib_name);
13 + if (l < 0 || l >= sizeof(pathbuf)) {
14 + // This really shouldn't happen
15 + fprintf(stderr, "Error prefixing library pathname\n");
18 + *handle = dlopen(pathbuf, flags);
24 fprintf(stderr, "Couldn't open %s: %s\n", lib_name, dlerror());