From b45ce825eb45eb68f1072cb0e0b48c0a41e425e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Tue, 23 Jan 2007 02:50:40 +0000 Subject: [PATCH] Do not %s-printf NULL-title of average balance plot. Fix #397935. The average balance report does not specify a title for the plot, so we must not printf it or GnuCash will crash on Windows. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15420 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-html-graph-gog.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gnome-utils/gnc-html-graph-gog.c b/src/gnome-utils/gnc-html-graph-gog.c index c5c4a03485..064cd09b6c 100644 --- a/src/gnome-utils/gnc-html-graph-gog.c +++ b/src/gnome-utils/gnc-html-graph-gog.c @@ -231,23 +231,22 @@ set_chart_titles_from_hash(GogObject *chart, GtkHTMLEmbedded * eb) static void set_chart_titles(GogObject *chart, const char *title, const char* sub_title) { - GString *totalTitle; - GOData *titleScalar; + gchar *my_sub_title, *total_title; + GOData *title_scalar; GogObject *tmp; - totalTitle = g_string_sized_new(32); - g_string_printf(totalTitle, "%s", title); - if (sub_title != NULL) - { - g_string_append_printf(totalTitle, " (%s)", sub_title); - } + if (sub_title) + my_sub_title = g_strdup_printf("%s(%s)", title ? " " : "", sub_title); + else + my_sub_title = g_strdup(""); + + total_title = g_strdup_printf("%s%s", title ? title : "", my_sub_title); tmp = gog_object_add_by_name(chart, "Title", NULL); - titleScalar = go_data_scalar_str_new(totalTitle->str, FALSE); - gog_dataset_set_dim(GOG_DATASET(tmp), 0, titleScalar, NULL); + title_scalar = go_data_scalar_str_new(total_title, TRUE); + gog_dataset_set_dim(GOG_DATASET(tmp), 0, title_scalar, NULL); - // @@fixme -- record or ref the string for freeing... - g_string_free(totalTitle, FALSE); + g_free(my_sub_title); } static void