gnucash unstable: Fix gnc_get_default_report_font_family returning bad string.
John Ralls
jralls at code.gnucash.org
Fri Jan 5 15:31:05 EST 2018
Updated via https://github.com/Gnucash/gnucash/commit/6a9972ac (commit)
from https://github.com/Gnucash/gnucash/commit/c0fd3b31 (commit)
commit 6a9972aced97778dc99ecd5b10f89ab551819efc
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Jan 5 12:27:39 2018 -0800
Fix gnc_get_default_report_font_family returning bad string.
pango_font_decription_get_family() returns a pointer into its struct,
which is immediately freed so the ptr points at garbage, which was
strduped.
Instead, do the strdup before freeing font_desc.
Also don't raise an error and do return a default value if run outside
the GUI.
diff --git a/gnucash/report/report-system/gnc-report.c b/gnucash/report/report-system/gnc-report.c
index 26edc19..2395bf8 100644
--- a/gnucash/report/report-system/gnc-report.c
+++ b/gnucash/report/report-system/gnc-report.c
@@ -207,24 +207,25 @@ gnc_get_default_report_font_family(void)
GtkWidget *top_widget;
PangoFontDescription *font_desc;
GtkStyleContext *top_widget_style_c;
- const gchar* default_font_family;
+ gchar *default_font_family;
top_list = gtk_window_list_toplevels();
- g_return_val_if_fail (top_list != NULL, NULL);
+ if (top_list == NULL)
+ return g_strdup ("Arial");
top_widget = GTK_WIDGET(top_list->data);
g_list_free(top_list);
top_widget_style_c = gtk_widget_get_style_context (top_widget);
gtk_style_context_get (top_widget_style_c, gtk_widget_get_state_flags (GTK_WIDGET(top_widget)),
"font", &font_desc, NULL);
- default_font_family = pango_font_description_get_family (font_desc);
+ default_font_family = g_strdup(pango_font_description_get_family (font_desc));
pango_font_description_free (font_desc);
if (default_font_family == NULL)
return g_strdup("Arial");
else
- return g_strdup(default_font_family);
+ return default_font_family;
}
static gboolean
Summary of changes:
gnucash/report/report-system/gnc-report.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
More information about the gnucash-changes
mailing list