From f8c342413b0c008670b87c47e57e322f7777ad16 Mon Sep 17 00:00:00 2001 From: "J. Alex Aycinena" Date: Mon, 13 Jun 2011 01:05:41 +0000 Subject: [PATCH] Correct memory handling of scm_to_locale_string per guile manual git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20755 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/glib-helpers.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/engine/glib-helpers.c b/src/engine/glib-helpers.c index 106674601b..f27b00262c 100644 --- a/src/engine/glib-helpers.c +++ b/src/engine/glib-helpers.c @@ -121,9 +121,17 @@ gnc_scm_to_glist_string(SCM list) while (!scm_is_null (list)) { - const gchar * str = scm_to_locale_string (SCM_CAR(list)); - if (str) - glist = g_list_prepend (glist, g_strdup (str)); + if (scm_is_string(SCM_CAR(list))) + { + char * str; + + scm_dynwind_begin (0); + str = scm_to_locale_string (SCM_CAR(list)); + if (str) + glist = g_list_prepend (glist, g_strdup (str)); + scm_dynwind_free (str); + scm_dynwind_end (); + } list = SCM_CDR (list); } @@ -137,9 +145,17 @@ gnc_scm_to_gslist_string(SCM list) while (!scm_is_null (list)) { - const gchar * str = scm_to_locale_string (SCM_CAR(list)); - if (str) - gslist = g_slist_prepend (gslist, g_strdup (str)); + if (scm_is_string(SCM_CAR(list))) + { + char * str; + + scm_dynwind_begin (0); + str = scm_to_locale_string (SCM_CAR(list)); + if (str) + gslist = g_slist_prepend (gslist, g_strdup (str)); + scm_dynwind_free (str); + scm_dynwind_end (); + } list = SCM_CDR (list); }