diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-09-28 00:47:53 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-09-28 00:47:53 +0200 |
commit | dd88123ad16ce27690a2aac94127175ed5213c64 (patch) | |
tree | c75809934a96765be1e1f7e8fdc10e8d65c16e71 | |
parent | 5cef3b469eb2ffa8e7b9f8758079b6fa414237e5 (diff) |
Dont use free'd fbconfigs
-rw-r--r-- | include/mgl/mgl.h | 1 | ||||
-rw-r--r-- | src/mgl.c | 15 |
2 files changed, 10 insertions, 6 deletions
diff --git a/include/mgl/mgl.h b/include/mgl/mgl.h index bd0ae5b..b43e4b9 100644 --- a/include/mgl/mgl.h +++ b/include/mgl/mgl.h @@ -10,6 +10,7 @@ typedef struct mgl_context mgl_context; struct mgl_context { mgl_connection connection; mgl_gl gl; + GLXFBConfig *fbconfigs; _XVisualInfo *visual_info; GLXFBConfig fbconfig; unsigned long wm_delete_window_atom; @@ -36,13 +36,14 @@ static int glx_context_init() { None }; + context.fbconfigs = NULL; context.visual_info = NULL; context.fbconfig = NULL; int numfbconfigs = 0; - GLXFBConfig *fbconfigs = context.gl.glXChooseFBConfig(context.connection, DefaultScreen(context.connection), attr, &numfbconfigs); + context.fbconfigs = context.gl.glXChooseFBConfig(context.connection, DefaultScreen(context.connection), attr, &numfbconfigs); for(int i = 0; i < numfbconfigs; i++) { - context.visual_info = context.gl.glXGetVisualFromFBConfig(context.connection, fbconfigs[i]); + context.visual_info = context.gl.glXGetVisualFromFBConfig(context.connection, context.fbconfigs[i]); if(!context.visual_info) continue; @@ -53,7 +54,7 @@ static int glx_context_init() { continue; } - context.fbconfig = fbconfigs[i]; + context.fbconfig = context.fbconfigs[i]; if(pict_format->direct.alphaMask > 0) break; @@ -62,9 +63,6 @@ static int glx_context_init() { context.fbconfig = NULL; } - if(fbconfigs) - XFree(fbconfigs); - if(!context.visual_info) { fprintf(stderr, "mgl error: no appropriate visual found\n"); return -1; @@ -78,6 +76,11 @@ static void glx_context_deinit() { XFree(context.visual_info); context.visual_info = NULL; } + + if(context.fbconfigs) { + XFree(context.fbconfigs); + context.fbconfigs = NULL; + } } int mgl_init(void) { |