Commit d4a07fbb by Geoff Lang

Disallow bit-shifting when the left operand is negative.

BUG=648063 Change-Id: I82d9fbdaf8791a396dd71eeb57d93967ba5d65bf Reviewed-on: https://chromium-review.googlesource.com/387115Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent a59fcdf4
......@@ -1492,7 +1492,7 @@ yyreduce:
case 18:
{
if ((yyvsp[0]) < 0)
if ((yyvsp[-1]) < 0 || (yyvsp[0]) < 0)
{
if (!context->isIgnoringErrors())
{
......@@ -1516,7 +1516,7 @@ yyreduce:
case 19:
{
if ((yyvsp[0]) < 0)
if ((yyvsp[-1]) < 0 || (yyvsp[0]) < 0)
{
if (!context->isIgnoringErrors())
{
......
......@@ -196,7 +196,7 @@ expression
$$ = $1 < $3;
}
| expression TOK_OP_RIGHT expression {
if ($3 < 0)
if ($2 < 0 || $3 < 0)
{
if (!context->isIgnoringErrors())
{
......@@ -216,7 +216,7 @@ expression
}
}
| expression TOK_OP_LEFT expression {
if ($3 < 0)
if ($2 < 0 || $3 < 0)
{
if (!context->isIgnoringErrors())
{
......
......@@ -1701,6 +1701,26 @@ TEST_F(MalformedShaderTest, LineDirectiveNegativeShift)
}
}
// Covers a bug in our parsing of malformed shift preprocessor expressions.
TEST_F(MalformedShaderTest, IfDirectiveNegativeLeftShift)
{
const std::string &shaderString = "#if -1 << 1";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// Covers a bug in our parsing of malformed shift preprocessor expressions.
TEST_F(MalformedShaderTest, IfDirectiveNegativeRightShift)
{
const std::string &shaderString = "#if -1 >> 1";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
// gl_MaxImageUnits is only available in ES 3.1 shaders.
TEST_F(MalformedShaderTest, MaxImageUnitsInES3Shader)
{
......
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