mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Fix potential crash due to iterator invalidation
This commit is contained in:
parent
5cd405bce8
commit
7c410ab5ce
@ -311,10 +311,14 @@ void CIdentifierStorage::finalize()
|
||||
state = FINALIZING;
|
||||
bool errorsFound = false;
|
||||
|
||||
//Note: we may receive new requests during resolution phase -> end may change -> range for can't be used
|
||||
for(auto it = scheduledRequests.begin(); it != scheduledRequests.end(); it++)
|
||||
while ( !scheduledRequests.empty() )
|
||||
{
|
||||
errorsFound |= !resolveIdentifier(*it);
|
||||
// Use local copy since new requests may appear during resolving, invalidating any iterators
|
||||
auto request = scheduledRequests.back();
|
||||
scheduledRequests.pop_back();
|
||||
|
||||
if (!resolveIdentifier(request))
|
||||
errorsFound = true;
|
||||
}
|
||||
|
||||
if (errorsFound)
|
||||
|
Loading…
Reference in New Issue
Block a user