Commit 3b43955c authored by Robert Morell's avatar Robert Morell Committed by Aaron Plattner
Browse files

Fix leaked extension info on library unload



In this sequence:
dlopen(libvdpau.so)
vdp_device_create_x11(dpy, ...)
dlclose(libvdpau.so)
XCloseDisplay(dpy)

the process will attempt to call the address at which DRI2CloseDisplay
was previously mapped, possibly resulting in a SEGV.

Instead of tracking displays to which we've added hooks and cleaning up
the extension on library unload or display close, simply clean up after
ourselves once we have the data we need.
Signed-off-by: default avatarRobert Morell <rmorell@nvidia.com>
Reviewed-by: default avatarAaron Plattner <aplattner@nvidia.com>
Tested-by: default avatarAaron Plattner <aplattner@nvidia.com>
Signed-off-by: default avatarAaron Plattner <aplattner@nvidia.com>
parent fb5f05b0
......@@ -42,7 +42,6 @@
static char dri2ExtensionName[] = DRI2_NAME;
static XExtensionInfo *dri2Info;
static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
static /* const */ XExtensionHooks dri2ExtensionHooks = {
NULL, /* create_gc */
......@@ -51,7 +50,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = {
NULL, /* free_gc */
NULL, /* create_font */
NULL, /* free_font */
DRI2CloseDisplay, /* close_display */
NULL, /* close_display */
NULL, /* wire_to_event */
NULL, /* event_to_wire */
NULL, /* error */
......@@ -75,6 +74,14 @@ _vdp_DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase)
return True;
}
if (dri2Info) {
if (info) {
XextRemoveDisplay(dri2Info, dpy);
}
XextDestroyExtension(dri2Info);
dri2Info = NULL;
}
return False;
}
......@@ -161,3 +168,11 @@ _vdp_DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName
return True;
}
void
_vdp_DRI2RemoveExtension(Display * dpy)
{
XextRemoveDisplay(dri2Info, dpy);
XextDestroyExtension(dri2Info);
dri2Info = NULL;
}
......@@ -47,4 +47,7 @@ extern Bool
_vdp_DRI2Connect(Display * display, XID window, char **driverName,
char **deviceName);
extern void
_vdp_DRI2RemoveExtension(Display * display);
#endif
......@@ -86,14 +86,17 @@ static char * _vdp_get_driver_name_from_dri2(
if (!_vdp_DRI2QueryVersion(display, &major, &minor) ||
(major < 1 || (major == 1 && minor < 2))) {
_vdp_DRI2RemoveExtension(display);
return NULL;
}
if (!_vdp_DRI2Connect(display, root, &driver_name, &device_name)) {
_vdp_DRI2RemoveExtension(display);
return NULL;
}
XFree(device_name);
_vdp_DRI2RemoveExtension(display);
#endif /* DRI2 */
return driver_name;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment