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/compile.h b/src/compiler/preprocessor/compile.h
index 69e3425..1180853 100644
--- a/src/compiler/preprocessor/compile.h
+++ b/src/compiler/preprocessor/compile.h
@@ -59,6 +59,7 @@
int DumpAtomTable;
} Options;
+#define MAX_IF_NESTING 64
struct CPPStruct_Rec {
// Public members
SourceLoc *pLastSourceLoc; // Set at the start of each statement by the tree walkers
@@ -80,7 +81,7 @@
// Private members:
SourceLoc ltokenLoc;
int ifdepth; //current #if-#else-#endif nesting in the cpp.c file (pre-processor)
- int elsedepth[64]; //Keep a track of #if depth..Max allowed is 64.
+ int elsedepth[MAX_IF_NESTING];//Keep a track of #if depth..Max allowed is 64.
int elsetracker; //#if-#else and #endif constructs...Counter.
const char *ErrMsg;
int CompileError; //Indicate compile error when #error, #else,#elif mismatch.