r21495 - gnucash/trunk/src/engine - Avoid double free of capital gains transactions when quitting

Mike Alexander mta at code.gnucash.org
Thu Oct 27 23:22:42 EDT 2011

Author: mta
Date: 2011-10-27 23:22:41 -0400 (Thu, 27 Oct 2011)
New Revision: 21495
Trac: http://svn.gnucash.org/trac/changeset/21495

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.

Modified: gnucash/trunk/src/engine/Transaction.c
--- gnucash/trunk/src/engine/Transaction.c	2011-10-27 21:08:05 UTC (rev 21494)
+++ gnucash/trunk/src/engine/Transaction.c	2011-10-28 03:22:41 UTC (rev 21495)
@@ -1173,8 +1173,10 @@
     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)

More information about the gnucash-changes mailing list