From de09259f13e8e3d7f2e50f97a353bd22eb45a4b6 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Sun, 17 Nov 2019 07:17:27 +0800 Subject: [PATCH] Bug 797500 - valgrind errors - new/delete vs malloc/free Mismatched new/g_free() Change to new/guid_free() which calls delete --- libgnucash/backend/xml/gnc-account-xml-v2.cpp | 4 ++-- libgnucash/backend/xml/gnc-bill-term-xml-v2.cpp | 4 ++-- libgnucash/backend/xml/gnc-book-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-budget-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-customer-xml-v2.cpp | 6 +++--- libgnucash/backend/xml/gnc-employee-xml-v2.cpp | 4 ++-- libgnucash/backend/xml/gnc-entry-xml-v2.cpp | 12 ++++++------ libgnucash/backend/xml/gnc-invoice-xml-v2.cpp | 10 +++++----- libgnucash/backend/xml/gnc-job-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-lot-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-order-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-owner-xml-v2.cpp | 4 ++-- libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-schedxaction-xml-v2.cpp | 2 +- libgnucash/backend/xml/gnc-tax-table-xml-v2.cpp | 6 +++--- libgnucash/backend/xml/gnc-transaction-xml-v2.cpp | 8 ++++---- libgnucash/backend/xml/gnc-vendor-xml-v2.cpp | 6 +++--- libgnucash/backend/xml/test/test-dom-converters1.cpp | 2 +- libgnucash/backend/xml/test/test-file-stuff.cpp | 4 ++-- libgnucash/backend/xml/test/test-xml-transaction.cpp | 10 +++++----- 20 files changed, 47 insertions(+), 47 deletions(-) diff --git a/libgnucash/backend/xml/gnc-account-xml-v2.cpp b/libgnucash/backend/xml/gnc-account-xml-v2.cpp index d88a7862a8..4feb75fae0 100644 --- a/libgnucash/backend/xml/gnc-account-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-account-xml-v2.cpp @@ -207,7 +207,7 @@ account_id_handler (xmlNodePtr node, gpointer act_pdata) xaccAccountSetGUID (pdata->account, guid); - g_free (guid); + guid_free (guid); return TRUE; } @@ -384,7 +384,7 @@ account_parent_handler (xmlNodePtr node, gpointer act_pdata) gnc_account_append_child (parent, pdata->account); - g_free (gid); + guid_free (gid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-bill-term-xml-v2.cpp b/libgnucash/backend/xml/gnc-bill-term-xml-v2.cpp index 379cdb540a..c61f042b9b 100644 --- a/libgnucash/backend/xml/gnc-bill-term-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-bill-term-xml-v2.cpp @@ -279,7 +279,7 @@ set_parent_child (xmlNodePtr node, struct billterm_pdata* pdata, gncBillTermSetGUID (term, guid); gncBillTermCommitEdit (term); } - g_free (guid); + guid_free (guid); g_return_val_if_fail (term, FALSE); func (pdata->term, term); @@ -318,7 +318,7 @@ billterm_guid_handler (xmlNodePtr node, gpointer billterm_pdata) gncBillTermSetGUID (pdata->term, guid); } - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-book-xml-v2.cpp b/libgnucash/backend/xml/gnc-book-xml-v2.cpp index 529eb2d933..e049eb7875 100644 --- a/libgnucash/backend/xml/gnc-book-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-book-xml-v2.cpp @@ -121,7 +121,7 @@ book_id_handler (xmlNodePtr node, gpointer book_pdata) guid = dom_tree_to_guid (node); qof_instance_set_guid (QOF_INSTANCE (book), guid); - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-budget-xml-v2.cpp b/libgnucash/backend/xml/gnc-budget-xml-v2.cpp index e9bef43b10..b30d203f40 100644 --- a/libgnucash/backend/xml/gnc-budget-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-budget-xml-v2.cpp @@ -109,7 +109,7 @@ budget_id_handler (xmlNodePtr node, gpointer bgt) guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); qof_instance_set_guid (QOF_INSTANCE (bgt), guid); - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-customer-xml-v2.cpp b/libgnucash/backend/xml/gnc-customer-xml-v2.cpp index 6473189319..dcaa9bff31 100644 --- a/libgnucash/backend/xml/gnc-customer-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-customer-xml-v2.cpp @@ -205,7 +205,7 @@ customer_guid_handler (xmlNodePtr node, gpointer cust_pdata) gncCustomerSetGUID (pdata->customer, guid); } - g_free (guid); + guid_free (guid); return TRUE; } @@ -237,7 +237,7 @@ customer_terms_handler (xmlNodePtr node, gpointer cust_pdata) g_return_val_if_fail (guid, FALSE); term = gnc_billterm_xml_find_or_create (pdata->book, guid); g_assert (term); - g_free (guid); + guid_free (guid); gncCustomerSetTerms (pdata->customer, term); return TRUE; @@ -353,7 +353,7 @@ customer_taxtable_handler (xmlNodePtr node, gpointer cust_pdata) gncTaxTableDecRef (taxtable); gncCustomerSetTaxTable (pdata->customer, taxtable); - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-employee-xml-v2.cpp b/libgnucash/backend/xml/gnc-employee-xml-v2.cpp index 559af22a75..5eec282a83 100644 --- a/libgnucash/backend/xml/gnc-employee-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-employee-xml-v2.cpp @@ -178,7 +178,7 @@ employee_guid_handler (xmlNodePtr node, gpointer employee_pdata) gncEmployeeSetGUID (pdata->employee, guid); } - g_free (guid); + guid_free (guid); return TRUE; } @@ -282,7 +282,7 @@ employee_ccard_handler (xmlNodePtr node, gpointer employee_pdata) g_return_val_if_fail (guid, FALSE); ccard_acc = xaccAccountLookup (guid, pdata->book); - g_free (guid); + guid_free (guid); g_return_val_if_fail (ccard_acc, FALSE); gncEmployeeSetCCard (pdata->employee, ccard_acc); diff --git a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp index a25fb56f15..25b88d9354 100644 --- a/libgnucash/backend/xml/gnc-entry-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-entry-xml-v2.cpp @@ -283,7 +283,7 @@ set_account (xmlNodePtr node, struct entry_pdata* pdata, guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); acc = xaccAccountLookup (guid, pdata->book); - g_free (guid); + guid_free (guid); g_return_val_if_fail (acc, FALSE); if (func) @@ -314,7 +314,7 @@ set_taxtable (xmlNodePtr node, struct entry_pdata* pdata, gncTaxTableDecRef (taxtable); func (pdata->entry, taxtable); - g_free (guid); + guid_free (guid); return TRUE; } @@ -339,7 +339,7 @@ entry_guid_handler (xmlNodePtr node, gpointer entry_pdata) gncEntrySetGUID (pdata->entry, guid); } - g_free (guid); + guid_free (guid); return TRUE; } @@ -579,7 +579,7 @@ entry_order_handler (xmlNodePtr node, gpointer entry_pdata) gncOrderAddEntry (order, pdata->entry); gncOrderCommitEdit (order); - g_free (guid); + guid_free (guid); return TRUE; } @@ -604,7 +604,7 @@ entry_invoice_handler (xmlNodePtr node, gpointer entry_pdata) gncInvoiceAddEntry (invoice, pdata->entry); gncInvoiceCommitEdit (invoice); - g_free (guid); + guid_free (guid); return TRUE; } @@ -629,7 +629,7 @@ entry_bill_handler (xmlNodePtr node, gpointer entry_pdata) gncBillAddEntry (invoice, pdata->entry); gncInvoiceCommitEdit (invoice); - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp index 4bb9ec0829..333fbe5d4c 100644 --- a/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-invoice-xml-v2.cpp @@ -214,7 +214,7 @@ invoice_guid_handler (xmlNodePtr node, gpointer invoice_pdata) gncInvoiceSetGUID (pdata->invoice, guid); } - g_free (guid); + guid_free (guid); return TRUE; } @@ -296,7 +296,7 @@ invoice_terms_handler (xmlNodePtr node, gpointer invoice_pdata) g_return_val_if_fail (guid, FALSE); term = gnc_billterm_xml_find_or_create (pdata->book, guid); g_assert (term); - g_free (guid); + guid_free (guid); gncInvoiceSetTerms (pdata->invoice, term); return TRUE; @@ -312,7 +312,7 @@ invoice_posttxn_handler (xmlNodePtr node, gpointer invoice_pdata) guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); txn = xaccTransLookup (guid, pdata->book); - g_free (guid); + guid_free (guid); g_return_val_if_fail (txn, FALSE); gncInvoiceSetPostedTxn (pdata->invoice, txn); @@ -329,7 +329,7 @@ invoice_postlot_handler (xmlNodePtr node, gpointer invoice_pdata) guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); lot = gnc_lot_lookup (guid, pdata->book); - g_free (guid); + guid_free (guid); g_return_val_if_fail (lot, FALSE); gncInvoiceSetPostedLot (pdata->invoice, lot); @@ -346,7 +346,7 @@ invoice_postacc_handler (xmlNodePtr node, gpointer invoice_pdata) guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); acc = xaccAccountLookup (guid, pdata->book); - g_free (guid); + guid_free (guid); g_return_val_if_fail (acc, FALSE); gncInvoiceSetPostedAcc (pdata->invoice, acc); diff --git a/libgnucash/backend/xml/gnc-job-xml-v2.cpp b/libgnucash/backend/xml/gnc-job-xml-v2.cpp index 9fb3cfc6cd..ba1ab367f3 100644 --- a/libgnucash/backend/xml/gnc-job-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-job-xml-v2.cpp @@ -146,7 +146,7 @@ job_guid_handler (xmlNodePtr node, gpointer job_pdata) gncJobSetGUID (pdata->job, guid); } - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-lot-xml-v2.cpp b/libgnucash/backend/xml/gnc-lot-xml-v2.cpp index f3f3c19f9e..8bccae7226 100644 --- a/libgnucash/backend/xml/gnc-lot-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-lot-xml-v2.cpp @@ -91,7 +91,7 @@ lot_id_handler (xmlNodePtr node, gpointer p) guid = dom_tree_to_guid (node); gnc_lot_set_guid (pdata->lot, *guid); - g_free (guid); + guid_free (guid); LEAVE (""); return TRUE; diff --git a/libgnucash/backend/xml/gnc-order-xml-v2.cpp b/libgnucash/backend/xml/gnc-order-xml-v2.cpp index a101d153fb..0b45ff9f01 100644 --- a/libgnucash/backend/xml/gnc-order-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-order-xml-v2.cpp @@ -161,7 +161,7 @@ order_guid_handler (xmlNodePtr node, gpointer order_pdata) gncOrderSetGUID (pdata->order, guid); } - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-owner-xml-v2.cpp b/libgnucash/backend/xml/gnc-owner-xml-v2.cpp index 0060e6c456..c9fc9ba989 100644 --- a/libgnucash/backend/xml/gnc-owner-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-owner-xml-v2.cpp @@ -182,11 +182,11 @@ owner_id_handler (xmlNodePtr node, gpointer owner_pdata) } default: PWARN ("Invalid owner type: %d\n", gncOwnerGetType (pdata->owner)); - g_free (guid); + guid_free (guid); return FALSE; } - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp b/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp index a8d228f1f8..be9b99afb3 100644 --- a/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-pricedb-xml-v2.cpp @@ -97,7 +97,7 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book) GncGUID* c = dom_tree_to_guid (sub_node); if (!c) return FALSE; gnc_price_set_guid (p, c); - g_free (c); + guid_free (c); } else if (g_strcmp0 ("price:commodity", (char*)sub_node->name) == 0) { diff --git a/libgnucash/backend/xml/gnc-schedxaction-xml-v2.cpp b/libgnucash/backend/xml/gnc-schedxaction-xml-v2.cpp index 7f5cf1845d..cb104e1a03 100644 --- a/libgnucash/backend/xml/gnc-schedxaction-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-schedxaction-xml-v2.cpp @@ -593,7 +593,7 @@ sx_templ_acct_handler (xmlNodePtr node, gpointer sx_pdata) account = xaccAccountLookup (templ_acct_guid, pdata->book); sx_set_template_account (sx, account); - g_free (templ_acct_guid); + guid_free (templ_acct_guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-tax-table-xml-v2.cpp b/libgnucash/backend/xml/gnc-tax-table-xml-v2.cpp index 05bf1974bd..b9206a6260 100644 --- a/libgnucash/backend/xml/gnc-tax-table-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-tax-table-xml-v2.cpp @@ -155,7 +155,7 @@ ttentry_acct_handler (xmlNodePtr node, gpointer ttentry_pdata) guid = dom_tree_to_guid (node); g_return_val_if_fail (guid, FALSE); acc = xaccAccountLookup (guid, pdata->book); - g_free (guid); + guid_free (guid); g_return_val_if_fail (acc, FALSE); gncTaxTableEntrySetAccount (pdata->ttentry, acc); @@ -257,7 +257,7 @@ set_parent_child (xmlNodePtr node, struct taxtable_pdata* pdata, gncTaxTableSetGUID (table, guid); gncTaxTableCommitEdit (table); } - g_free (guid); + guid_free (guid); g_return_val_if_fail (table, FALSE); func (pdata->table, table); @@ -285,7 +285,7 @@ taxtable_guid_handler (xmlNodePtr node, gpointer taxtable_pdata) gncTaxTableSetGUID (pdata->table, guid); } - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp index e7c4c92f86..b4aad73092 100644 --- a/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-transaction-xml-v2.cpp @@ -237,7 +237,7 @@ spl_id_handler (xmlNodePtr node, gpointer data) xaccSplitSetGUID (pdata->split, tmp); - g_free (tmp); + guid_free (tmp); return TRUE; } @@ -316,7 +316,7 @@ spl_account_handler (xmlNodePtr node, gpointer data) xaccAccountInsertSplit (account, pdata->split); - g_free (id); + guid_free (id); return TRUE; } @@ -340,7 +340,7 @@ spl_lot_handler (xmlNodePtr node, gpointer data) gnc_lot_add_split (lot, pdata->split); - g_free (id); + guid_free (id); return TRUE; } @@ -455,7 +455,7 @@ trn_id_handler (xmlNodePtr node, gpointer trans_pdata) xaccTransSetGUID ((Transaction*)trn, tmp); - g_free (tmp); + guid_free (tmp); return TRUE; } diff --git a/libgnucash/backend/xml/gnc-vendor-xml-v2.cpp b/libgnucash/backend/xml/gnc-vendor-xml-v2.cpp index b01f6b2e53..983e4f2586 100644 --- a/libgnucash/backend/xml/gnc-vendor-xml-v2.cpp +++ b/libgnucash/backend/xml/gnc-vendor-xml-v2.cpp @@ -190,7 +190,7 @@ vendor_guid_handler (xmlNodePtr node, gpointer vendor_pdata) gncVendorSetGUID (pdata->vendor, guid); } - g_free (guid); + guid_free (guid); return TRUE; } @@ -222,7 +222,7 @@ vendor_terms_handler (xmlNodePtr node, gpointer vendor_pdata) g_return_val_if_fail (guid, FALSE); term = gnc_billterm_xml_find_or_create (pdata->book, guid); g_assert (term); - g_free (guid); + guid_free (guid); gncVendorSetTerms (pdata->vendor, term); return TRUE; @@ -298,7 +298,7 @@ vendor_taxtable_handler (xmlNodePtr node, gpointer vendor_pdata) gncTaxTableDecRef (taxtable); gncVendorSetTaxTable (pdata->vendor, taxtable); - g_free (guid); + guid_free (guid); return TRUE; } diff --git a/libgnucash/backend/xml/test/test-dom-converters1.cpp b/libgnucash/backend/xml/test/test-dom-converters1.cpp index aa2b6c3f92..fe63368419 100644 --- a/libgnucash/backend/xml/test/test-dom-converters1.cpp +++ b/libgnucash/backend/xml/test/test-dom-converters1.cpp @@ -251,7 +251,7 @@ test_dom_tree_to_guid (void) xmlFreeNode (test_node); g_free (test_guid1); - g_free (test_guid2); + guid_free (test_guid2); } } diff --git a/libgnucash/backend/xml/test/test-file-stuff.cpp b/libgnucash/backend/xml/test/test-file-stuff.cpp index bde3bd6731..1ba6e974e5 100644 --- a/libgnucash/backend/xml/test/test-file-stuff.cpp +++ b/libgnucash/backend/xml/test/test-file-stuff.cpp @@ -209,12 +209,12 @@ equals_node_val_vs_guid (xmlNodePtr node, const GncGUID* id) if (guid_compare (cmpid, id) == 0) { - g_free (cmpid); + guid_free (cmpid); return TRUE; } else { - g_free (cmpid); + guid_free (cmpid); return FALSE; } } diff --git a/libgnucash/backend/xml/test/test-xml-transaction.cpp b/libgnucash/backend/xml/test/test-xml-transaction.cpp index 4d54ef5e48..2389206828 100644 --- a/libgnucash/backend/xml/test/test-xml-transaction.cpp +++ b/libgnucash/backend/xml/test/test-xml-transaction.cpp @@ -90,7 +90,7 @@ find_appropriate_node (xmlNodePtr node, Split* spl) { account_guid_good = TRUE; } - g_free (accid); + guid_free (accid); } if (account_guid_good && amount_good) @@ -116,10 +116,10 @@ equals_node_val_vs_split_internal (xmlNodePtr node, Split* spl) if (!guid_equal (id, xaccSplitGetGUID (spl))) { - g_free (id); + guid_free (id); return "ids differ"; } - g_free (id); + guid_free (id); } else if (g_strcmp0 ((char*)mark->name, "split:memo") == 0) { @@ -191,10 +191,10 @@ equals_node_val_vs_split_internal (xmlNodePtr node, Split* spl) if (!guid_equal (id, xaccAccountGetGUID (account))) { - g_free (id); + guid_free (id); return "accounts differ"; } - g_free (id); + guid_free (id); } } return NULL;