Commit 85d624a5 by Olli Etuaho Committed by Geoff Lang

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/603368Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 6a6199b4
...@@ -3005,7 +3005,7 @@ TIntermFunctionPrototype *TParseContext::createPrototypeNodeFromFunction( ...@@ -3005,7 +3005,7 @@ TIntermFunctionPrototype *TParseContext::createPrototypeNodeFromFunction(
} }
else else
{ {
error(location, "redefinition", variable->getName().c_str()); error(location, "redefinition", param.name->c_str());
} }
} }
} }
......
...@@ -4324,3 +4324,25 @@ TEST_F(FragmentShaderValidationTest, InvalidUseOfMaxVertices) ...@@ -4324,3 +4324,25 @@ TEST_F(FragmentShaderValidationTest, InvalidUseOfMaxVertices)
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog; 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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment