diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c index f4ad3cb66b..fc5220795d 100644 --- a/libgnucash/engine/gncInvoice.c +++ b/libgnucash/engine/gncInvoice.c @@ -760,12 +760,13 @@ void gncInvoiceSortEntries (GncInvoice *invoice) void gncInvoiceRemoveEntries (GncInvoice *invoice) { - GList *node; - if (!invoice) return; - for (node = invoice->entries; node; node = node->next) + // gnc{Bill,Invoice}RemoveEntry free the "entry" node. + // Make sure to save "next" first. + for (GList *next, *node = invoice->entries; node; node = next) { + next = node->next; GncEntry *entry = node->data; switch (gncInvoiceGetOwnerType (invoice)) diff --git a/libgnucash/engine/test/test-engine-kvp-properties.c b/libgnucash/engine/test/test-engine-kvp-properties.c index 7a11dfd050..6491f36e79 100644 --- a/libgnucash/engine/test/test-engine-kvp-properties.c +++ b/libgnucash/engine/test/test-engine-kvp-properties.c @@ -142,7 +142,7 @@ test_account_kvp_properties (Fixture *fixture, gconstpointer pData) gchar *ab_acct_id = "1234-5678-9087"; gchar *ab_bank_code = "0032340"; gchar *online_id_r, *ab_acct_id_r, *ab_bank_code_r; - GncGUID *ofx_income_acct = guid_malloc (); + GncGUID *ofx_income_acct = guid_new (); GncGUID *ofx_income_acct_r; Time64 trans_retr = {gnc_time(NULL)}; Time64 *trans_retr_r; @@ -186,8 +186,8 @@ test_account_kvp_properties (Fixture *fixture, gconstpointer pData) static void test_trans_kvp_properties (Fixture *fixture, gconstpointer pData) { - GncGUID *invoice = guid_malloc (); - GncGUID *from_sx = guid_malloc (); + GncGUID *invoice = guid_new (); + GncGUID *from_sx = guid_new (); GncGUID *invoice_r, *from_sx_r; gchar *online_id = "my online id"; gchar *online_id_r; @@ -227,7 +227,7 @@ test_split_kvp_properties (Fixture *fixture, gconstpointer pData) gchar *online_id = "my_online_id"; gchar *debit_formula_r, *credit_formula_r, *sx_shares_r; gchar *online_id_r; - GncGUID *sx_account = guid_malloc (); + GncGUID *sx_account = guid_new (); GncGUID *sx_account_r; gnc_numeric debit_numeric = gnc_numeric_create (123, 456); gnc_numeric credit_numeric = gnc_numeric_create (789, 456); @@ -285,11 +285,11 @@ test_split_kvp_properties (Fixture *fixture, gconstpointer pData) static void test_lot_kvp_properties (Fixture *fixture, gconstpointer pData) { - GncGUID *invoice = guid_malloc (); + GncGUID *invoice = guid_new (); GncGUID *invoice_r; gint64 owner_type = 47; gint64 owner_type_r; - GncGUID *owner = guid_malloc (); + GncGUID *owner = guid_new (); GncGUID *owner_r; qof_begin_edit (QOF_INSTANCE (fixture->lot)); @@ -322,8 +322,8 @@ test_customer_kvp_properties (Fixture *fixture, gconstpointer pData) { gchar *pdf_dir = "/foo/bar/baz"; gchar *pdf_dir_r; - GncGUID *inv_acct = guid_malloc (); - GncGUID *pmt_acct = guid_malloc (); + GncGUID *inv_acct = guid_new (); + GncGUID *pmt_acct = guid_new (); GncGUID *inv_acct_r, *pmt_acct_r; qof_begin_edit (QOF_INSTANCE (fixture->cust)); @@ -358,8 +358,8 @@ test_employee_kvp_properties (Fixture *fixture, gconstpointer pData) { gchar *pdf_dir = "/foo/bar/baz"; gchar *pdf_dir_r; - GncGUID *inv_acct = guid_malloc (); - GncGUID *pmt_acct = guid_malloc (); + GncGUID *inv_acct = guid_new (); + GncGUID *pmt_acct = guid_new (); GncGUID *inv_acct_r, *pmt_acct_r; qof_begin_edit (QOF_INSTANCE (fixture->emp)); @@ -417,8 +417,8 @@ test_vendor_kvp_properties (Fixture *fixture, gconstpointer pData) { gchar *pdf_dir = "/foo/bar/baz"; gchar *pdf_dir_r; - GncGUID *inv_acct = guid_malloc (); - GncGUID *pmt_acct = guid_malloc (); + GncGUID *inv_acct = guid_new (); + GncGUID *pmt_acct = guid_new (); GncGUID *inv_acct_r, *pmt_acct_r; qof_begin_edit (QOF_INSTANCE (fixture->vend)); diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp index 0a0f676ae9..3c86a780b4 100644 --- a/libgnucash/engine/test/utest-Transaction.cpp +++ b/libgnucash/engine/test/utest-Transaction.cpp @@ -881,6 +881,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData) frame->set({"qux", "quux", "corge"}, new KvpValue(123.456)); xaccTransCommitEdit (clone); g_free (cleanup->msg); + cleanup->msg = NULL; g_free (check->msg); check->msg = g_strdup ("[xaccSplitEqual] GUIDs differ"); auto split1 = xaccTransGetSplit (clone, 0);