Don't attempt to perform constant folding with an uninitialized constant variable.
BUG=348205
Change-Id: I9be17832b1a35d2995725ab147977992c2732274
Reviewed-on: https://chromium-review.googlesource.com/188711
Tested-by: Nicolas Capens <nicolascapens@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/189471
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index bec0e29..74b9a6e 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -222,11 +222,10 @@
//
// See if we can fold constants.
//
- TIntermTyped* typedReturnNode = 0;
TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
if (leftTempConstant && rightTempConstant) {
- typedReturnNode = leftTempConstant->fold(node->getOp(), rightTempConstant, infoSink);
+ TIntermTyped *typedReturnNode = leftTempConstant->fold(node->getOp(), rightTempConstant, infoSink);
if (typedReturnNode)
return typedReturnNode;
@@ -1251,6 +1250,10 @@
TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
{
ConstantUnion *unionArray = getUnionArrayPointer();
+
+ if (!unionArray)
+ return 0;
+
size_t objectSize = getType().getObjectSize();
if (constantNode)
@@ -1260,6 +1263,9 @@
ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
TType returnType = getType();
+ if (!rightUnionArray)
+ return 0;
+
// for a case like float f = 1.2 + vec4(2,3,4,5);
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1)
{