From f2612dea85a5b8bcfa0df36a5cd87f8976b6d052 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Sat, 5 Sep 2009 13:16:20 +0000 Subject: [PATCH] Fix bug 587891: Memory leak - results of gnc-build-url git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18294 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/html/gnc-html.c | 33 +++++++++++++++++++++++-- src/html/gnc-html.h | 2 ++ src/report/report-gnome/window-report.c | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/html/gnc-html.c b/src/html/gnc-html.c index c1be7486a8..227029581e 100644 --- a/src/html/gnc-html.c +++ b/src/html/gnc-html.c @@ -564,8 +564,37 @@ gnc_html_initialize( void ) gnc_html_register_urltype (types[i].type, types[i].protocol); } -char * -gnc_build_url (URLType type, const gchar * location, const gchar * label) +/** + * Creates a new HMTL url. + * + * @param type URL type + * @param location URL location + * @param label URL label (optional) + * @return Newly created URL. This string must be *NOT* freed by the caller. + */ +gchar* +gnc_build_url( URLType type, const gchar* location, const gchar* label ) +{ + static gchar buf[1000]; + gchar* url; + + url = gnc_html_build_url( type, location, label ); + strncpy( buf, url, sizeof(buf) ); + g_free( url ); + + return buf; +} + +/** + * Creates a new HMTL url. + * + * @param type URL type + * @param location URL location + * @param label URL label (optional) + * @return Newly created URL. This string must be freed by the caller. + */ +gchar* +gnc_html_build_url( URLType type, const gchar* location, const gchar* label ) { char * type_name; diff --git a/src/html/gnc-html.h b/src/html/gnc-html.h index 6136c624a4..a618ed0aff 100644 --- a/src/html/gnc-html.h +++ b/src/html/gnc-html.h @@ -265,4 +265,6 @@ void gnc_html_unregister_url_handler( URLType url_type ); const gchar* gnc_html_get_embedded_param( gpointer eb, const gchar* param_name ); +gchar* gnc_html_build_url( URLType type, const gchar* location, const gchar* label ); + #endif diff --git a/src/report/report-gnome/window-report.c b/src/report/report-gnome/window-report.c index b3ae92f464..5f8c5d0377 100644 --- a/src/report/report-gnome/window-report.c +++ b/src/report/report-gnome/window-report.c @@ -283,7 +283,7 @@ gnc_html_report_url_cb (const char *location, const char *label, { char *url; - url = gnc_build_url (URL_TYPE_REPORT, location, label); + url = gnc_html_build_url (URL_TYPE_REPORT, location, label); gnc_main_window_open_report_url (url, NULL); g_free (url);