diff --git a/src/app-utils/guile-util.c b/src/app-utils/guile-util.c index 920e524e99..37e58e416f 100644 --- a/src/app-utils/guile-util.c +++ b/src/app-utils/guile-util.c @@ -150,7 +150,7 @@ initialize_scm_functions() * * * Args: func - the guile function to call * * arg - the single function argument * - * Returns: malloc'ed char * or NULL * + * Returns: g_malloc'ed char * or NULL * \********************************************************************/ char * gnc_guile_call1_to_string(SCM func, SCM arg) @@ -162,7 +162,18 @@ gnc_guile_call1_to_string(SCM func, SCM arg) value = scm_call_1(func, arg); if (scm_is_string(value)) - return scm_to_locale_string(value); + { + char* x; + gchar* s; + + x = scm_to_locale_string(value); + + /* scm_to_locale_string() returns a malloc'ed string. + Copy to a g_malloc'ed one. */ + s = g_strdup(x); + free(x); + return s; + } else { PERR("bad value\n"); @@ -650,6 +661,8 @@ char * gnc_split_scm_get_memo(SCM split_scm) { SCM result; + char* x; + gchar* s; initialize_scm_functions(); @@ -660,7 +673,13 @@ gnc_split_scm_get_memo(SCM split_scm) if (!scm_is_string(result)) return NULL; - return scm_to_locale_string(result); + x = scm_to_locale_string(result); + + /* scm_to_locale_string() returns a malloc'ed string. + Copy to a g_malloc'ed one. */ + s = g_strdup(x); + free(x); + return s; } @@ -675,6 +694,8 @@ char * gnc_split_scm_get_action(SCM split_scm) { SCM result; + char* x; + gchar* s; initialize_scm_functions(); @@ -685,7 +706,13 @@ gnc_split_scm_get_action(SCM split_scm) if (!scm_is_string(result)) return NULL; - return scm_to_locale_string(result); + x = scm_to_locale_string(result); + + /* scm_to_locale_string() returns a malloc'ed string. + Copy to a g_malloc'ed one. */ + s = g_strdup(x); + free(x); + return s; } @@ -1100,6 +1127,8 @@ gnc_get_debit_string(GNCAccountType account_type) const gchar *string; SCM result; SCM arg; + char* x; + gchar* s; initialize_scm_functions(); @@ -1115,7 +1144,13 @@ gnc_get_debit_string(GNCAccountType account_type) if (!scm_is_string(result)) return NULL; - return scm_to_locale_string(result); + x = scm_to_locale_string(result); + + /* scm_to_locale_string() returns a malloc'ed string. + Copy to a g_malloc'ed one. */ + s = g_strdup(x); + free(x); + return s; } @@ -1132,6 +1167,8 @@ gnc_get_credit_string(GNCAccountType account_type) const gchar *string; SCM result; SCM arg; + char* x; + gchar* s; initialize_scm_functions(); @@ -1147,7 +1184,13 @@ gnc_get_credit_string(GNCAccountType account_type) if (!scm_is_string(result)) return NULL; - return scm_to_locale_string(result); + x = scm_to_locale_string(result); + + /* scm_to_locale_string() returns a malloc'ed string. + Copy to a g_malloc'ed one. */ + s = g_strdup(x); + free(x); + return s; } diff --git a/src/gnome-utils/gnc-menu-extensions.c b/src/gnome-utils/gnc-menu-extensions.c index f480700a44..a7b586d906 100644 --- a/src/gnome-utils/gnc-menu-extensions.c +++ b/src/gnome-utils/gnc-menu-extensions.c @@ -171,18 +171,20 @@ gnc_extension_path (SCM extension, char **fullpath) if (scm_is_string(item)) { + char* s; + + s = scm_to_locale_string(item); + if (i == 1) { - strings[i] = scm_to_locale_string(item); + + strings[i] = g_strdup(s); } else { - gchar* s; - - s = scm_to_locale_string(item); strings[i] = g_strdup(gettext(s)); - free(s); } + free(s); } else { @@ -283,8 +285,8 @@ gnc_create_extension_info (SCM extension) ext_info->ae.stock_id = NULL; ext_info->ae.accelerator = NULL; ext_info->ae.callback = NULL; - free(name); - free(guid); + g_free(name); + g_free(guid); tmp = g_strdup_printf("%s/%s", ext_info->path, ext_info->ae.label); ext_info->sort_key = g_utf8_collate_key(tmp, -1);