Discussion:
[SDL] [PATCH] Fix a memory leak in X11_GL_CreateContext
Tapani Pälli
2016-11-01 07:23:48 UTC
Permalink
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 <***@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
Tapani Pälli
2016-11-02 05:54:20 UTC
Permalink
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.
Cheers,
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)
---
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
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...