Mesa (vulkan): xlib: do not cache return value of glXChooseVisual/ glXGetVisualFromFBConfig
Jason Ekstrand
jekstrand at kemper.freedesktop.org
Fri Apr 15 20:48:18 UTC 2016
Module: Mesa
Branch: vulkan
Commit: fe9d8cd79e9380e29eb92f97903e8cb79d25371a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe9d8cd79e9380e29eb92f97903e8cb79d25371a
Author: John Sheu <sheu at google.com>
Date: Wed Apr 13 13:57:42 2016 -0700
xlib: do not cache return value of glXChooseVisual/glXGetVisualFromFBConfig
The returned XVisualInfo from glXChooseVisual/glXGetVisualFromFBConfig
is being cached in XMesaVisual.vishandle (and unconditionally
overwritten on subsequent calls). However, these entry points are
specified to return XVisualInfo instances to be owned by the caller and
freed with XFree(), so the return values should not be retained.
With this change, XMesaVisual.vishandle is essentially unused and will
be removed in a subsequent change.
v2: update commit message
Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
---
src/mesa/drivers/x11/fakeglx.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 2f4d966..d62d5ab 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -1241,16 +1241,11 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
xmvis = choose_visual(dpy, screen, list, GL_FALSE);
if (xmvis) {
-#if 0
- return xmvis->vishandle;
-#else
- /* create a new vishandle - the cached one may be stale */
- xmvis->vishandle = malloc(sizeof(XVisualInfo));
- if (xmvis->vishandle) {
- memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
+ XVisualInfo* visinfo = malloc(sizeof(XVisualInfo));
+ if (visinfo) {
+ memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo));
}
- return xmvis->vishandle;
-#endif
+ return visinfo;
}
else
return NULL;
@@ -1974,16 +1969,11 @@ Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
{
if (dpy && config) {
XMesaVisual xmvis = (XMesaVisual) config;
-#if 0
- return xmvis->vishandle;
-#else
- /* create a new vishandle - the cached one may be stale */
- xmvis->vishandle = malloc(sizeof(XVisualInfo));
- if (xmvis->vishandle) {
- memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
+ XVisualInfo* visinfo = malloc(sizeof(XVisualInfo));
+ if (visinfo) {
+ memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo));
}
- return xmvis->vishandle;
-#endif
+ return visinfo;
}
else {
return NULL;
More information about the mesa-commit
mailing list