mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix crashes in test-engine on Arch Linux.
Root cause is mutating a list while it's iterating. We're able to protect it in two cases, have to copy it in xaccTransScrubGainsDate.
This commit is contained in:
parent
946fbb12c5
commit
1020bde89c
@ -1342,6 +1342,12 @@ xaccFreeAccount (Account *acc)
|
||||
priv = GET_PRIVATE(acc);
|
||||
qof_event_gen (&acc->inst, QOF_EVENT_DESTROY, NULL);
|
||||
|
||||
/* Otherwise the lists below get munged while we're iterating
|
||||
* them, possibly crashing.
|
||||
*/
|
||||
if (!qof_instance_get_destroying (acc))
|
||||
qof_instance_set_destroying(acc, TRUE);
|
||||
|
||||
if (priv->children)
|
||||
{
|
||||
PERR (" instead of calling xaccFreeAccount(), please call\n"
|
||||
|
@ -2924,7 +2924,8 @@ static void
|
||||
xaccTransScrubGainsDate (Transaction *trans)
|
||||
{
|
||||
SplitList *node;
|
||||
for (node = trans->splits; node; node = node->next)
|
||||
SplitList *splits_copy = g_list_copy(trans->splits);
|
||||
for (node = splits_copy; node; node = node->next)
|
||||
{
|
||||
Split *s = node->data;
|
||||
|
||||
@ -2943,6 +2944,7 @@ xaccTransScrubGainsDate (Transaction *trans)
|
||||
FOR_EACH_SPLIT(trans, s->gains &= ~GAINS_STATUS_DATE_DIRTY);
|
||||
}
|
||||
}
|
||||
g_list_free(splits_copy);
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
@ -1427,6 +1427,9 @@ test_do_destroy (GainsFixture *fixture, gconstpointer pData)
|
||||
g_object_ref (base->txn);
|
||||
g_object_ref (fixture->gains_txn);
|
||||
|
||||
/* Protect against recursive calls to do_destroy from xaccTransCommitEdit */
|
||||
xaccTransBeginEdit(base->txn);
|
||||
|
||||
base->func->do_destroy (base->txn);
|
||||
g_assert_cmpint (test_signal_return_hits (sig), ==, 1);
|
||||
g_assert (base->txn->description == NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user