Skip to content

Commit

Permalink
Original splits are not freed in xaccTransRollbackEdit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bob-IT committed Aug 15, 2021
1 parent cacdb12 commit 71d73be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libgnucash/engine/Transaction.c
Expand Up @@ -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;
Expand All @@ -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
{
Expand All @@ -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;

Expand Down

0 comments on commit 71d73be

Please sign in to comment.