Fix buffer overflows in eve.c (sf.net #3034056)
[monky] / src / fonts.c
index b110d10..6067bf2 100644 (file)
@@ -10,7 +10,7 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  *     (see AUTHORS)
  * All rights reserved.
  *
@@ -58,7 +58,7 @@ void setup_fonts(void)
                        window.xftdraw = 0;
                }
                window.xftdraw = XftDrawCreate(display, window.drawable,
-                               DefaultVisual(display, screen), DefaultColormap(display, screen));
+                               window.visual, window.colourmap);
        }
 #endif /* XFT */
        set_font();
@@ -135,7 +135,13 @@ void free_fonts(void)
        for (i = 0; i <= font_count; i++) {
 #ifdef XFT
                if (use_xft) {
-                       XftFontClose(display, fonts[i].xftfont);
+                       /*
+                        * Do we not need to close fonts with Xft? Unsure.  Not freeing the
+                        * fonts seems to incur a slight memory leak, but it also prevents
+                        * a crash.
+                        *
+                        * XftFontClose(display, fonts[i].xftfont);
+                        */
                        fonts[i].xftfont = 0;
                } else
 #endif /* XFT */