Fix: free_fonts tries sometimes tries to free much
authorNikolas Garofil <garo@dunaldi.garofil.be>
Sun, 12 Jul 2009 16:29:50 +0000 (18:29 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Sun, 12 Jul 2009 16:29:50 +0000 (18:29 +0200)
When build with support for x11 and ran with a empty config this resulted in a segfault.

src/fonts.c

index 61c7b85..0870129 100644 (file)
@@ -31,6 +31,7 @@
 int selected_font = 0;
 int font_count = -1;
 struct font_list *fonts = NULL;
+char fontloaded = 0;
 
 void set_font(void)
 {
@@ -120,7 +121,7 @@ void free_fonts(void)
 {
        int i;
 
-       if ((output_methods & TO_X) == 0) {
+       if ((output_methods & TO_X) == 0 || fontloaded == 0) {
                return;
        }
        for (i = 0; i <= font_count; i++) {
@@ -189,4 +190,5 @@ void load_fonts(void)
                        }
                }
        }
+       fontloaded = 1;
 }