From 7b46466ebd8e8a74ec49610813b2c73f86e9aa3e Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 13 May 2024 12:42:26 +0800 Subject: [PATCH] [account.cpp] fix regression caused by 3f7a5a8267 whereby deleting an account and moving all splits to another account would segfault. make a copy of priv->splits and work on the copy rather than the original. --- libgnucash/engine/Account.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index 1fcd9928d9..e82fb8d9c0 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -2251,8 +2251,8 @@ xaccAccountMoveAllSplits (Account *accfrom, Account *accto) * Convert each split's amount to accto's commodity. * Commit to editing each transaction. */ - std::for_each (from_priv->splits.begin(), from_priv->splits.end(), - [accto](Split *s){ xaccPostSplitMove (s, accto); }); + auto splits = from_priv->splits; + std::for_each (splits.begin(), splits.end(), [accto](auto s){ xaccPostSplitMove (s, accto); }); /* Finally empty accfrom. */ g_assert(from_priv->splits.empty());