From 19c2a53dc0d42fdbeac74ef2d848e32f238c2634 Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Mon, 22 Feb 2016 19:42:21 +0100 Subject: [PATCH] Free visualinfo and picture format info structures Fixes a memory leak. --- src/glx_context.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/glx_context.c b/src/glx_context.c index 7d9cc0e1a..fedfc50d4 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -79,7 +79,9 @@ 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.