gnucash maint: [import-main-matcher] plug Hash Table & GList leaks.

Christopher Lam clam at code.gnucash.org
Sun Jul 17 03:36:51 EDT 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/85af9156 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a000c05c (commit)



commit 85af91569c62203f3a4e88075af40fb1b1ee6828
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Jul 17 14:58:22 2022 +0800

    [import-main-matcher] plug Hash Table & GList leaks.
    
    A couple of hash tables were not destroyed.
    
    GList* list was being modified to NULL therefore not freed with
    g_list_free_full.

diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c
index 9ab11f1e9..54c9b9016 100644
--- a/gnucash/import-export/import-main-matcher.c
+++ b/gnucash/import-export/import-main-matcher.c
@@ -221,7 +221,9 @@ gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
     // We've deferred balance computations on many accounts. Let's do it now that we're done.
     update_all_balances (info);
 
+    gnc_import_PendingMatches_delete (info->pending_matches);
     g_hash_table_foreach_remove (info->acct_id_hash, delete_hash, NULL);
+    g_hash_table_destroy (info->acct_id_hash);
     info->acct_id_hash = NULL;
     g_free (info);
 }
@@ -1052,10 +1054,10 @@ gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
     {
         // Unselect rows that should not be selectable
         GList* list = gtk_tree_selection_get_selected_rows (selection, &model);
-        for ( ; list; list=list->next)
+        for (GList *n = list; n; n = n->next)
         {
-            if (get_action_for_path (list->data, model) != GNCImport_ADD)
-                gtk_tree_selection_unselect_path (selection, list->data);
+            if (get_action_for_path (n->data, model) != GNCImport_ADD)
+                gtk_tree_selection_unselect_path (selection, n->data);
         }
         g_list_free_full (list, (GDestroyNotify)gtk_tree_path_free);
     }



Summary of changes:
 gnucash/import-export/import-main-matcher.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)



More information about the gnucash-changes mailing list