Fixed infinite loop crash
Writing for(;;) in a shader was crashing because
a NULL condition was dereferenced. Added the
NULL pointer check to fix the crash.
Change-Id: I2be7a4594029c928ff83221f65503636bc28f4a9
Reviewed-on: https://swiftshader-review.googlesource.com/3553
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index 67aada7..1c54252 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -1275,7 +1275,10 @@
}
else
{
- condition->traverse(this);
+ if(condition)
+ {
+ condition->traverse(this);
+ }
emit(sw::Shader::OPCODE_WHILE, 0, condition);
@@ -1291,7 +1294,10 @@
expression->traverse(this);
}
- condition->traverse(this);
+ if(condition)
+ {
+ condition->traverse(this);
+ }
emit(sw::Shader::OPCODE_ENDWHILE);
}