mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 799389 - Crash when removing an account
Destroying the split vector from front->back crashes halfway through because the iterators aren't updated as we remove items from the vector. Iterating in reverse works because the remaining elements aren't moved as we delete.
This commit is contained in:
@@ -1546,8 +1546,9 @@ xaccAccountCommitEdit (Account *acc)
|
||||
themselves will be destroyed by the transaction code */
|
||||
if (!qof_book_shutting_down(book))
|
||||
{
|
||||
for (auto s : priv->splits)
|
||||
xaccSplitDestroy (s);
|
||||
// We need to delete in reverse order so that the vector's iterators aren't invalidated.
|
||||
for_each(priv->splits.rbegin(), priv->splits.rend(), [](Split *s) {
|
||||
xaccSplitDestroy (s); });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user