gnucash maint: Bug 797500 - valgrind errors - new/delete vs malloc/free
Christopher Lam
clam at code.gnucash.org
Sat Nov 16 20:56:09 EST 2019
Updated via https://github.com/Gnucash/gnucash/commit/de09259f (commit)
from https://github.com/Gnucash/gnucash/commit/78cd4eaa (commit)
commit de09259f13e8e3d7f2e50f97a353bd22eb45a4b6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Nov 17 07:17:27 2019 +0800
Bug 797500 - valgrind errors - new/delete vs malloc/free
Mismatched new/g_free()
Change to new/guid_free() which calls delete
diff --git a/libgnucash/backend/xml/gnc-account-xml-v2.cpp b/libgnucash/backend/xml/gnc-account-xml-v2.cpp
index d88a7862a..4feb75fae 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 379cdb540..c61f042b9 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 529eb2d93..e049eb787 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 e9bef43b1..b30d203f4 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 647318931..dcaa9bff3 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 559af22a7..5eec282a8 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 a25fb56f1..25b88d935 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 4bb9ec082..333fbe5d4 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 9fb3cfc6c..ba1ab367f 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 f3f3c19f9..8bccae722 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 a101d153f..0b45ff9f0 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 0060e6c45..c9fc9ba98 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 a8d228f1f..be9b99afb 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 7f5cf1845..cb104e1a0 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 05bf1974b..b9206a626 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 e7c4c92f8..b4aad7309 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 b01f6b2e5..983e4f258 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 aa2b6c3f9..fe6336841 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 bde3bd673..1ba6e974e 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 4d54ef5e4..238920682 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;
Summary of changes:
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(-)
More information about the gnucash-changes
mailing list