r20735 - gnucash/trunk/src/report/report-gnome - Correct memory leak found with Valgrind.

J. Alex Aycinena alex.aycinena at code.gnucash.org
Fri Jun 3 23:37:38 EDT 2011


Author: alex.aycinena
Date: 2011-06-03 23:37:38 -0400 (Fri, 03 Jun 2011)
New Revision: 20735
Trac: http://svn.gnucash.org/trac/changeset/20735

Modified:
   gnucash/trunk/src/report/report-gnome/dialog-custom-report.c
Log:
Correct memory leak found with Valgrind.

Modified: gnucash/trunk/src/report/report-gnome/dialog-custom-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/dialog-custom-report.c	2011-06-03 23:54:55 UTC (rev 20734)
+++ gnucash/trunk/src/report/report-gnome/dialog-custom-report.c	2011-06-04 03:37:38 UTC (rev 20735)
@@ -119,8 +119,13 @@
         	 in the gtkliststore */
         for (i = 0; !scm_is_null(names); i++)
         {
+            char * str;
 
-            name = scm_to_locale_string(scm_call_2(template_menu_name, SCM_CAR(names), SCM_BOOL_F));
+            scm_dynwind_begin (0); 
+            str = scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names), SCM_BOOL_F));
+            name = g_strdup (str);
+            scm_dynwind_free (str); 
+            scm_dynwind_end (); 
 
             gtk_list_store_append(store, &iter);
             gtk_list_store_set(store, &iter,
@@ -297,15 +302,21 @@
 
     SCM template_menu_name = scm_c_eval_string("gnc:report-template-menu-name/report-guid");
     SCM guid;
-    const gchar* report_name;
+    gchar* report_name;
 
     sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(crd->reportview));
 
     guid = get_custom_report_selection(crd, _("You must select a report to delete."));
     if (!scm_is_null(guid))
     {
-        report_name = scm_to_locale_string(scm_call_2(template_menu_name, guid, SCM_BOOL_F));
+        char * str;
 
+        scm_dynwind_begin (0); 
+        str = scm_to_locale_string(scm_call_2(template_menu_name, guid, SCM_BOOL_F));
+        report_name = g_strdup (str);
+        scm_dynwind_free (str); 
+        scm_dynwind_end (); 
+
         /* we must confirm the user wants to delete their precious custom report! */
         if (gnc_verify_dialog(crd->dialog, FALSE, "Are you sure you want to delete %s?", report_name))
         {
@@ -314,6 +325,7 @@
             update_report_list(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(crd->reportview))),
                                crd);
         }
+        g_free (report_name);
     }
 }
 



More information about the gnucash-changes mailing list