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/CodeGen.cpp b/src/compiler/translator/CodeGen.cpp
index 4f8d2b0..2b376d7 100644
--- a/src/compiler/translator/CodeGen.cpp
+++ b/src/compiler/translator/CodeGen.cpp
@@ -40,11 +40,11 @@
 #else
         // This compiler is not supported in this
         // configuration. Return NULL per the ShConstructCompiler API.
-        return NULL;
+        return nullptr;
 #endif // ANGLE_ENABLE_HLSL
       default:
         // Unknown format. Return NULL per the ShConstructCompiler API.
-        return NULL;
+        return nullptr;
     }
 }
 
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)) {