From 9369eae6d7ea9932e5e2be51b9ea1d562b3a0141 Mon Sep 17 00:00:00 2001 From: Mike Alexander Date: Fri, 28 Oct 2011 03:22:41 +0000 Subject: [PATCH] Avoid double free of capital gains transactions when quitting If an register is open on an account that has capital gains transactions created by the lot scrubber when you quit Gnucash, a capital gains transaction may be freed twice since it is freed when the associated sale is freed and again when it is encountered on the list of transactions to be freed. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21495 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Transaction.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index c12bfa3af7..03f63c975d 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -1173,8 +1173,10 @@ do_destroy (Transaction *trans) gboolean shutting_down = qof_book_shutting_down(qof_instance_get_book(trans)); /* If there are capital-gains transactions associated with this, - * they need to be destroyed too. */ - destroy_gains (trans); + * they need to be destroyed too unless we're shutting down in + * which case all transactions will be destroyed. */ + if (!shutting_down) + destroy_gains (trans); /* Make a log in the journal before destruction. */ if (!shutting_down)