diff options
author | John Sheu <[email protected]> | 2016-04-01 16:52:21 -0700 |
---|---|---|
committer | Alejandro Piñeiro <[email protected]> | 2016-04-15 07:45:46 +0200 |
commit | 8a9c0f102540f64c4a3523f6b4e11eaa2071e0a3 (patch) | |
tree | 0fb7f2ecc1c15d6b159a05fa5e02275b8b80398a /src/mesa/drivers | |
parent | 781232e0ac48bf608757bbd270c593a90173f951 (diff) |
xlib: fix leaks of returned values from XGetVisualInfo
Reviewed-by: Alejandro Piñeiro <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/x11/fakeglx.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 208fc5bbc60..508dc65e785 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -730,27 +730,39 @@ choose_x_overlay_visual( Display *dpy, int scr, vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask, &vistemplate, &count ); + if (!vislist) { + /* no matches */ + continue; + } + if (count!=1) { /* something went wrong */ + free(vislist); continue; } if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) { /* wrong visual class */ + free(vislist); continue; } /* Color-index rendering is not supported. Make sure we have True/DirectColor */ - if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) + if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) { + free(vislist); continue; + } - if (deepvis==NULL || vislist->depth > deepest) { - /* YES! found a satisfactory visual */ - free(deepvis); - deepest = vislist->depth; - deepvis = vislist; - /* DEBUG tt = ov->transparent_type;*/ - /* DEBUG tv = ov->value; */ + if (deepvis!=NULL && vislist->depth <= deepest) { + free(vislist); + continue; } + + /* YES! found a satisfactory visual */ + free(deepvis); + deepest = vislist->depth; + deepvis = vislist; + /* DEBUG tt = ov->transparent_type;*/ + /* DEBUG tv = ov->value; */ } /*DEBUG @@ -1912,6 +1924,7 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) for (i = 0; i < *nelements; i++) { results[i] = create_glx_visual(dpy, visuals + i); } + free(visuals); return (GLXFBConfig *) results; } return NULL; |