Skip to content

ResourceGatheringManager::findBestSupplyCenter tries to erase an element with an iterator on an unrelated container #342

Closed
@andrew-2e128

Description

@andrew-2e128

I was testing with jmarshall2323's fork, however the bug exists in the original source code

Affected Files:
Generals/Code/GameEngine/Source/Common/RTS/ResourceGatheringManager.cpp
GeneralsMD/Code/GameEngine/Source/Common/RTS/ResourceGatheringManager.cpp

iterator = m_supplyWarehouses.erase( iterator );

the function findBestSupplyCenter seems to have been copied from findBestSupplyWarehouse the specified line above seems to have been left unmodified after being copied, so it is using an iterator of m_supplyCenters to erase an element in m_supplyWarehouses

this throws an error in modern builds (jmarshall2323's) but I have no clue what it would have done back in the day with VS6.0 era STL

this does not affect game play in anyway, as the loop will just skip it and keep going, at wrost it would be slightly slower, but with modern versions it throws an exception as this is an illegal write

solution:
basically replace m_supplyWarehouses with m_supplyCenters at both of those lines as this is the correct behavior

iterator = m_supplyWarehouses.erase( iterator );

Metadata

Metadata

Assignees

No one assigned

    Labels

    GenRelates to GeneralsMinorSeverity: Minor < Major < Critical < BlockerZHRelates to Zero Hour

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions