Fix a mem corruption in ANGLE translator.

Basically outside TCompile::compile(), the global parse context is
invalid, and should never be queried.

BUG=angle:568
TEST=webgl conformance tests, no crash

Change-Id: I5573ce2bf3bf838ab24f59dda00948f60a0b023d
Reviewed-on: https://chromium-review.googlesource.com/197178
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Tested-by: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 36b313e..ca459b3 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -28,12 +28,11 @@
      return spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC;
 }
 
-size_t GetGlobalMaxTokenSize()
+size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
 {
-    TParseContext *parseContext = GetGlobalParseContext();
     // WebGL defines a max token legnth of 256, while ES2 leaves max token
     // size undefined. ES3 defines a max size of 1024 characters.
-    if (IsWebGLBasedSpec(parseContext->shaderSpec))
+    if (IsWebGLBasedSpec(spec))
     {
         return 256;
     }
@@ -261,7 +260,7 @@
 
     // Cleanup memory.
     intermediate.remove(parseContext.treeRoot);
-
+    SetGlobalParseContext(NULL);
     return success;
 }