*/
static __DRIdriver *OpenDriver(const char *driverName)
{
+ void *glhandle = NULL;
char *libPaths = NULL;
char libDir[1000];
int i;
}
}
+ /* Attempt to make sure libGL symbols will be visible to the driver */
+ glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
+
if (geteuid() == getuid()) {
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
libPaths = getenv("LIBGL_DRIVERS_PATH");
/* allocate __DRIdriver struct */
driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver));
if (!driver)
- return NULL; /* out of memory! */
+ break; /* out of memory! */
/* init the struct */
driver->name = __glXstrdup(driverName);
if (!driver->name) {
Xfree(driver);
- return NULL; /* out of memory! */
+ driver = NULL;
+ break; /* out of memory! */
}
driver->createNewScreenFunc = (PFNCREATENEWSCREENFUNC)
"Your driver may be too old for this libGL.\n",
createNewScreenName, driverName);
Xfree(driver);
+ driver = NULL;
dlclose(handle);
continue;
}
/* put at head of linked list */
driver->next = Drivers;
Drivers = driver;
- return driver;
+ break;
}
else {
ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
}
}
- ErrorMessageF("unable to find driver: %s_dri.so\n", driverName);
- return NULL;
+ if (!driver)
+ ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
+
+ if (glhandle)
+ dlclose(glhandle);
+
+ return driver;
}