[PATCH] Fix a memory leak in X11_GL_CreateContext

Tapani Pälli <[email protected]>
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
Patch uses XFree to free the memory returned by glXChooseFBConfig.

--- 8< ---
==21042== 512 bytes in 1 blocks are definitely lost in loss record 114 of 134
==21042==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==21042==    by 0x518E4F3: glXGetFBConfigs (glxcmds.c:1690)
==21042==    by 0x518F6DE: glXChooseFBConfig (glxcmds.c:1608)
==21042==    by 0x4F23A64: X11_GL_CreateContext (SDL_x11opengl.c:642)

Signed-off-by: Tapani Pälli <[email protected]>
---
 src/video/x11/SDL_x11opengl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c
index abc699d..f7264b7 100644
--- a/src/video/x11/SDL_x11opengl.c
+++ b/src/video/x11/SDL_x11opengl.c
@@ -649,6 +649,8 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
                                                     framebuffer_config[0],
                                                     share_context, True, attribs);
                 }
+                if (framebuffer_config)
+                    X11_XFree(framebuffer_config);
             }
         }
         X11_XFree(vinfo);
-- 
2.7.4

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.