Add bounds check for shaders

This commit is contained in:
Lwmte 2024-12-26 16:13:41 +01:00
parent 8fb4668dfc
commit c67e777271

View file

@ -138,7 +138,15 @@ namespace TEN::Renderer::Utils
void ShaderManager::Bind(Shader shader, bool forceNull)
{
const auto& shaderObj = _shaders[(int)shader];
int shaderIndex = (int)shader;
if (shaderIndex >= _shaders.size())
{
TENLog("Attempt to access nonexistent shader with index " + std::to_string(shaderIndex), LogLevel::Error);
return;
}
const auto& shaderObj = _shaders[shaderIndex];
if (shaderObj.Vertex.Shader != nullptr || forceNull)
_context->VSSetShader(shaderObj.Vertex.Shader.Get(), nullptr, 0);