r20755 - gnucash/trunk/src/engine - Correct memory handling of scm_to_locale_string per guile manual

J. Alex Aycinena alex.aycinena at code.gnucash.org
Sun Jun 12 21:05:41 EDT 2011


Author: alex.aycinena
Date: 2011-06-12 21:05:41 -0400 (Sun, 12 Jun 2011)
New Revision: 20755
Trac: http://svn.gnucash.org/trac/changeset/20755

Modified:
   gnucash/trunk/src/engine/glib-helpers.c
Log:
Correct memory handling of scm_to_locale_string per guile manual

Modified: gnucash/trunk/src/engine/glib-helpers.c
===================================================================
--- gnucash/trunk/src/engine/glib-helpers.c	2011-06-12 19:54:06 UTC (rev 20754)
+++ gnucash/trunk/src/engine/glib-helpers.c	2011-06-13 01:05:41 UTC (rev 20755)
@@ -121,9 +121,17 @@
 
     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 @@
 
     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);
     }
 



More information about the gnucash-changes mailing list