mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 08:09:32 +02:00
Fix dangling list iterator bug, detected by MSVC debug library
This commit is contained in:
parent
d420fdecf4
commit
c3403054c3
@ -1087,27 +1087,24 @@ void TrackList::ClearPendingTracks( ListOfTracks *pAdded )
|
|||||||
|
|
||||||
// To find the first node that remains after the first deleted one
|
// To find the first node that remains after the first deleted one
|
||||||
TrackNodePointer node;
|
TrackNodePointer node;
|
||||||
bool findingNode = false;
|
|
||||||
bool foundNode = false;
|
bool foundNode = false;
|
||||||
|
|
||||||
for (auto it = ListOfTracks::begin(), stop = ListOfTracks::end();
|
for (auto it = ListOfTracks::begin(), stop = ListOfTracks::end();
|
||||||
it != stop;) {
|
it != stop;) {
|
||||||
if (it->get()->GetId() == TrackId{}) {
|
if (it->get()->GetId() == TrackId{}) {
|
||||||
if (pAdded)
|
do {
|
||||||
pAdded->push_back( *it );
|
if (pAdded)
|
||||||
(*it)->SetOwner( {}, {} );
|
pAdded->push_back( *it );
|
||||||
it = erase( it );
|
(*it)->SetOwner( {}, {} );
|
||||||
|
it = erase( it );
|
||||||
|
}
|
||||||
|
while (it != stop && it->get()->GetId() == TrackId{});
|
||||||
|
|
||||||
if (!findingNode)
|
|
||||||
findingNode = true;
|
|
||||||
if (!foundNode && it != stop)
|
if (!foundNode && it != stop)
|
||||||
node = (*it)->GetNode();
|
node = (*it)->GetNode(), foundNode = true;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if ( findingNode )
|
|
||||||
foundNode = true;
|
|
||||||
++it;
|
++it;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty()) {
|
if (!empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user