Commit aaa62521 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Ensure that the lhs of an assignment is reducible to a variable.

parent 18b8393f
......@@ -1456,6 +1456,29 @@ static unsigned int invert_swizzle(unsigned int *swizzle, unsigned int writemask
return new_writemask;
}
static BOOL validate_lhs_deref(const struct hlsl_ir_node *lhs)
{
struct hlsl_ir_deref *deref;
if (lhs->type != HLSL_IR_DEREF)
{
hlsl_report_message(lhs->loc, HLSL_LEVEL_ERROR, "invalid lvalue");
return FALSE;
}
deref = deref_from_node(lhs);
if (deref->src.type == HLSL_IR_DEREF_VAR)
return TRUE;
if (deref->src.type == HLSL_IR_DEREF_ARRAY)
return validate_lhs_deref(deref->src.v.array.array);
if (deref->src.type == HLSL_IR_DEREF_RECORD)
return validate_lhs_deref(deref->src.v.record.record);
assert(0);
return FALSE;
}
struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign_op assign_op,
struct hlsl_ir_node *rhs)
{
......@@ -1509,6 +1532,12 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
lhs = lhs_inner;
}
if (!validate_lhs_deref(lhs))
{
d3dcompiler_free(assign);
return NULL;
}
TRACE("Creating proper assignment expression.\n");
if (writemask == BWRITERSP_WRITEMASK_ALL)
type = lhs->data_type;
......
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