Fix a memory leak when setting summaryview and folderview fonts.
[claws.git] / src / folderview.c
index 83dc21936fb14e894204cc787ccca5d07d1832ab..42c3fe077b7bbbcc9085e6cec5b4ce0f4158ebe8 100644 (file)
@@ -2717,8 +2717,19 @@ void folderview_reflect_prefs(void)
        last_boldfont = g_strdup(BOLD_FONT);
        last_derive = prefs_common.derive_from_normal_font;
 
-       normal_style = normal_color_style = bold_style =
-               bold_color_style = bold_tgtfold_style = NULL;
+#define STYLE_FREE(s)                  \
+       if (s != NULL) {                \
+               g_object_unref(s);      \
+               s = NULL;               \
+       }
+
+       STYLE_FREE(normal_style);
+       STYLE_FREE(normal_color_style);
+       STYLE_FREE(bold_style);
+       STYLE_FREE(bold_color_style);
+       STYLE_FREE(bold_tgtfold_style);
+
+#undef STYLE_FREE
 
        folderview_init(folderview);
        gtk_cmclist_freeze(GTK_CMCLIST(folderview->ctree));