Fix issues with preprocessor on very malformed shaders
Trac #15236,#15237,#15238,#15239
Error out instead of continued processing when we already know the preprocessor directives are bungled.
Generally be more careful about the order in which cpp->elsetracker and cpp->ifdepth are checked/operated on.
Validate all accesses of cpp->elsedepth to ensure no out of bounds accesses occur.
Also slipped in a few indentation/spacing fixes.
Signed-off-by: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/trunk@540 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/preprocessor/cppstruct.c b/src/compiler/preprocessor/cppstruct.c
index 8e142bc..58cff31 100644
--- a/src/compiler/preprocessor/cppstruct.c
+++ b/src/compiler/preprocessor/cppstruct.c
@@ -92,12 +92,12 @@
cpp->lastSourceLoc.file = 0;
cpp->lastSourceLoc.line = 0;
- cpp->pC=0;
- cpp->CompileError=0;
- cpp->ifdepth=0;
- for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
- cpp->elsedepth[cpp->elsetracker]=0;
- cpp->elsetracker=0;
+ cpp->pC = 0;
+ cpp->CompileError = 0;
+ cpp->ifdepth = 0;
+ for(cpp->elsetracker = 0; cpp->elsetracker < MAX_IF_NESTING; cpp->elsetracker++)
+ cpp->elsedepth[cpp->elsetracker] = 0;
+ cpp->elsetracker = 0;
cpp->tokensBeforeEOF = 0;
return 1;
}