free visualinfo and picture format info structures (plug a memory leak)

This commit is contained in:
Wolfgang Draxinger 2016-02-22 19:42:21 +01:00
parent da33cc3923
commit de4835e0d6

View File

@ -80,6 +80,8 @@ static GLFWbool chooseFBConfig(
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0;
XVisualInfo *visualinfo = NULL;
XRenderPictFormat *pictFormat = NULL;
selectionloop:
for (i = 0; i < nativeCount; i++)
{
@ -98,13 +100,21 @@ selectionloop:
}
if( findTransparent ) {
XVisualInfo *visualinfo;
XRenderPictFormat *pictFormat;
if( visualinfo ) {
XFree( visualinfo );
visualinfo = NULL;
}
visualinfo = glXGetVisualFromFBConfig(_glfw.x11.display, n);
if (!visualinfo)
continue;
if( pictFormat ) {
XFree( pictFormat );
pictFormat = NULL;
}
pictFormat = XRenderFindVisualFormat(_glfw.x11.display, visualinfo->visual);
if( !pictFormat )
continue;
@ -141,6 +151,15 @@ selectionloop:
u->glx = n;
usableCount++;
if( visualinfo ) {
XFree( visualinfo );
visualinfo = NULL;
}
if( pictFormat ) {
XFree( pictFormat );
pictFormat = NULL;
}
}
// reiterate the selection loop without looking for transparency supporting
// formats if no matchig FB configs for a transparent window were found.