mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Fix potential crash due to iterator invalidation
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user