Fixed Program::getAttachedShaders
It was possible to have "count" larger than "maxCount"
since "total" was incremented regardless of whether or
not the shader was added to the "shaders" output
argument. Simplified the function to fix it.
Change-Id: I403e6c100580fb8f5f1c6fe170af1a796e936828
Reviewed-on: https://swiftshader-review.googlesource.com/3605
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp
index 81045ee..2e78c2c 100644
--- a/src/OpenGL/libGLESv2/Program.cpp
+++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -2367,24 +2367,14 @@
{
int total = 0;
- if(vertexShader)
+ if(vertexShader && (total < maxCount))
{
- if(total < maxCount)
- {
- shaders[total] = vertexShader->getName();
- }
-
- total++;
+ shaders[total++] = vertexShader->getName();
}
- if(fragmentShader)
+ if(fragmentShader && (total < maxCount))
{
- if(total < maxCount)
- {
- shaders[total] = fragmentShader->getName();
- }
-
- total++;
+ shaders[total++] = fragmentShader->getName();
}
if(count)