Skip to content

Commit

Permalink
RTSS: check the result of std::find to prevent erasing 'end' iterator (
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankGoyens authored Nov 24, 2022
1 parent e355af3 commit 0df846d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Components/RTShaderSystem/src/OgreShaderProgramManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void ProgramManager::releasePrograms(const ProgramSet* programSet)
if(prg.use_count() > ResourceGroupManager::RESOURCE_SYSTEM_NUM_REFERENCE_COUNTS + 2)
continue;

mShaderList.erase(std::find(mShaderList.begin(), mShaderList.end(), prg));
const auto it = std::find(mShaderList.begin(), mShaderList.end(), prg);
// TODO: this check should not be necessary, but we observed strange prg.use_count() in the wild
if(it != mShaderList.end())
mShaderList.erase(it);
GpuProgramManager::getSingleton().remove(prg);
}
}
Expand Down

0 comments on commit 0df846d

Please sign in to comment.