patch by a_grue: fix some memory leaks in the GLX client - the manpages confirm that...
authorblub <blub@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 4 Jan 2010 10:56:38 +0000 (10:56 +0000)
committerblub <blub@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 4 Jan 2010 10:56:38 +0000 (10:56 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9776 d7cf8633-e32d-0410-b094-e92efae38249

vid_glx.c

index 0ed0c38..01d2486 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -1016,6 +1016,9 @@ qboolean VID_InitMode(viddef_mode_t *mode)
        }
 
        XmbSetWMProperties(vidx11_display, win, gamename, gamename, (char **) com_argv, com_argc, szhints, wmhints, clshints);
+       // strdup() allocates using malloc(), should be freed with free()
+       free(clshints->res_name);
+       free(clshints->res_class);
        XFree(clshints);
        XFree(wmhints);
        XFree(szhints);
@@ -1042,6 +1045,7 @@ qboolean VID_InitMode(viddef_mode_t *mode)
        //XSync(vidx11_display, False);
 
        ctx = qglXCreateContext(vidx11_display, visinfo, NULL, True);
+       XFree(visinfo); // glXChooseVisual man page says to use XFree to free visinfo
        if (!ctx)
        {
                Con_Printf ("glXCreateContext failed\n");
@@ -1153,6 +1157,8 @@ size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)
                                ++k;
                        }
                }
+               // manpage of XF86VidModeGetAllModeLines says it should be freed by the caller
+               XFree(vidmodes);
                return k;
        }
        return 0; // FIXME implement this