OSDN Git Service

Fixed infinite loop crash
authorAlexis Hetu <sugoi@google.com>
Tue, 23 Jun 2015 20:37:15 +0000 (16:37 -0400)
committerAlexis Hétu <sugoi@google.com>
Thu, 25 Jun 2015 15:43:16 +0000 (15:43 +0000)
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>
src/OpenGL/compiler/OutputASM.cpp

index 67aada7..1c54252 100644 (file)
@@ -1275,7 +1275,10 @@ namespace glsl
                        }\r
                        else\r
                        {\r
-                               condition->traverse(this);\r
+                               if(condition)\r
+                               {\r
+                                       condition->traverse(this);\r
+                               }\r
 \r
                                emit(sw::Shader::OPCODE_WHILE, 0, condition);\r
 \r
@@ -1291,7 +1294,10 @@ namespace glsl
                                        expression->traverse(this);\r
                                }\r
 \r
-                               condition->traverse(this);\r
+                               if(condition)\r
+                               {\r
+                                       condition->traverse(this);\r
+                               }\r
 \r
                                emit(sw::Shader::OPCODE_ENDWHILE);\r
                        }\r