Don't crash when calling ShConstructCompiler with a wrong output

BUG=angleproject:446

Change-Id: Ic1c326f79105950e5c3eb8724eba12fca187a2ec
Reviewed-on: https://chromium-review.googlesource.com/316610
Tryjob-Request: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/ShaderLang.cpp b/src/compiler/translator/ShaderLang.cpp
index 6abfcd1..e257f93 100644
--- a/src/compiler/translator/ShaderLang.cpp
+++ b/src/compiler/translator/ShaderLang.cpp
@@ -189,9 +189,16 @@
                              const ShBuiltInResources* resources)
 {
     TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output));
-    TCompiler* compiler = base->getAsCompiler();
-    if (compiler == 0)
+    if (base == nullptr)
+    {
         return 0;
+    }
+
+    TCompiler* compiler = base->getAsCompiler();
+    if (compiler == nullptr)
+    {
+        return 0;
+    }
 
     // Generate built-in symbol table.
     if (!compiler->Init(*resources)) {