From 71d73beb6cd87fb0d4f59f3a3c1ae46867c73baf Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sat, 17 Jul 2021 14:26:44 +0100 Subject: [PATCH] Original splits are not freed in xaccTransRollbackEdit At the beginning of a transactions edit, xaccTransBeginEdit is used and part of that duplicates the existing splits so that they can be restored if editing is cancelled. If cancelled, xaccTransRollbackEdit is used to restore the origin splits but if a split was not changed, the copy was not being freed so loop over the original split list and free them. --- libgnucash/engine/Transaction.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c index 4890c2f0154..f9ea4e684f5 100644 --- a/libgnucash/engine/Transaction.c +++ b/libgnucash/engine/Transaction.c @@ -1769,7 +1769,7 @@ xaccTransRollbackEdit (Transaction *trans) xaccSplitRollbackEdit(s); SWAP_STR(s->action, so->action); SWAP_STR(s->memo, so->memo); - qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so)); + qof_instance_copy_kvp (QOF_INSTANCE (s), QOF_INSTANCE (so)); s->reconciled = so->reconciled; s->amount = so->amount; s->value = so->value; @@ -1778,7 +1778,6 @@ xaccTransRollbackEdit (Transaction *trans) //SET_GAINS_A_VDIRTY(s); s->date_reconciled = so->date_reconciled; qof_instance_mark_clean(QOF_INSTANCE(s)); - xaccFreeSplit(so); } else { @@ -1805,6 +1804,10 @@ xaccTransRollbackEdit (Transaction *trans) } } g_list_free(slist); + + // orig->splits may still have duped splits so free them + for (node = orig->splits; node; node = node->next) + xaccFreeSplit(node->data); g_list_free(orig->splits); orig->splits = NULL;