[PATCH] Fix a memory leak in X11_GL_CreateContext

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 <@Tapani_Palli>—
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

Got it, thanks!


In general it’s helpful to submit a bug to http://bugzilla.libsdl.org so
that patches don’t get lost on the mailing list.

Cheers,On Tue, Nov 1, 2016 at 12:23 AM, Tapani P?lli <tapani.palli at intel.com> wrote:

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 <tapani.palli at intel.com>

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Got it, thanks!

https://hg.libsdl.org/SDL/rev/0cbc922ef093

In general it’s helpful to submit a bug to http://bugzilla.libsdl.org so
that patches don’t get lost on the mailing list.

No problem, I was not sure how the development workflow for SDL looks
like. I also sent another small fix:

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2016-November/100828.html

I’ll make sure to open up bugs for any new upcoming patches.On 11/01/2016 07:47 PM, Sam Lantinga wrote:

Cheers,

On Tue, Nov 1, 2016 at 12:23 AM, Tapani P?lli <@Tapani_Palli mailto:Tapani_Palli> wrote:

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 <@Tapani_Palli
<mailto:@Tapani_Palli>>
---
 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
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org