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
This commit is contained in:
Phil Longstaff 2009-09-05 13:16:20 +00:00
parent 27965d9484
commit f2612dea85
3 changed files with 34 additions and 3 deletions

View File

@ -564,8 +564,37 @@ gnc_html_initialize( void )
gnc_html_register_urltype (types[i].type, types[i].protocol); 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; char * type_name;

View File

@ -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 ); 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 #endif

View File

@ -283,7 +283,7 @@ gnc_html_report_url_cb (const char *location, const char *label,
{ {
char *url; 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); gnc_main_window_open_report_url (url, NULL);
g_free (url); g_free (url);