Skip to content

Commit 8e594bc

Browse files
committed
Fix index-out-of-bounds crash when getting shader param substring.
1 parent ed5f2d9 commit 8e594bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libprojectM/Renderer/ShaderEngine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
255255

256256
if (texDesc.first == NULL)
257257
{
258-
if (lowerCaseName.substr(0, 4) == "rand" || lowerCaseName.substr(2, 5) == "_rand")
258+
if ((lowerCaseName.size() >= 4 && lowerCaseName.substr(0, 4) == "rand") ||
259+
(lowerCaseName.size() >= 5 && lowerCaseName.substr(2, 5) == "_rand"))
259260
{
260261
texDesc = textureManager->getRandomTextureName(sampler);
261262
}

0 commit comments

Comments
 (0)