From 14fe4d862f9cd797fb947bc20403b9cf4bb9eece Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Fri, 7 Oct 2022 22:02:35 +0800 Subject: [PATCH] Bug 798629 - gnucash crashes attempting to import OFX file It's not correct to g_free id if the g_hash_table_insert returns FALSE; returning FALSE means the key/value pair was replaced. The key will automatically be freed by glib thanks to the new_hash having a GDestroyNotify g_free: GHashTable* new_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); --- gnucash/import-export/import-backend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gnucash/import-export/import-backend.c b/gnucash/import-export/import-backend.c index b843164830..14a1da1075 100644 --- a/gnucash/import-export/import-backend.c +++ b/gnucash/import-export/import-backend.c @@ -1219,8 +1219,7 @@ gboolean gnc_import_exists_online_id (Transaction *trans, GHashTable* acct_id_ha if (gnc_import_split_has_online_id (n->data)) { char *id = gnc_import_get_split_online_id (n->data); - if (!g_hash_table_insert (new_hash, (void*) id, GINT_TO_POINTER (1))) - g_free (id); + g_hash_table_insert (new_hash, (void*) id, GINT_TO_POINTER (1)); } } }