Fix null pointer dereference in redeclaration error message

When a function parameter name conflicts with another, the pointer
returned to ParseContext will be null.

BUG=chromium:745242
TEST=angle_unittests

Change-Id: Ie53bb06b0c6660e382d85aeda41f3a1b7df5a917
Reviewed-on: https://chromium-review.googlesource.com/603368
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 7fa3b0e..a4796e3 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -3005,7 +3005,7 @@
                 }
                 else
                 {
-                    error(location, "redefinition", variable->getName().c_str());
+                    error(location, "redefinition", param.name->c_str());
                 }
             }
         }
diff --git a/src/tests/compiler_tests/ShaderValidation_test.cpp b/src/tests/compiler_tests/ShaderValidation_test.cpp
index 8ed5c0e..82069fd 100644
--- a/src/tests/compiler_tests/ShaderValidation_test.cpp
+++ b/src/tests/compiler_tests/ShaderValidation_test.cpp
@@ -4324,3 +4324,25 @@
         FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
     }
 }
+
+// Test that using the same variable name twice in function parameters fails without crashing.
+TEST_F(FragmentShaderValidationTest, RedefinedParamInFunctionHeader)
+{
+    const std::string &shaderString =
+        "#version 300 es\n"
+        "precision mediump float;\n"
+        "out vec4 my_FragColor;\n"
+        "void foo(int a, float a)\n"
+        "{\n"
+        "    return;\n"
+        "}\n"
+        "void main()\n"
+        "{\n"
+        "    my_FragColor = vec4(0.0);\n"
+        "}\n";
+
+    if (compile(shaderString))
+    {
+        FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
+    }
+}