[PATCH 5/5] d3dcompiler: Ensure that the lhs of an assignment is reducible to a variable.
Zebediah Figura
z.figura12 at gmail.com
Sun Mar 15 16:25:13 CDT 2020
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/d3dcompiler_43/utils.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 921ef7c2c7b..6e9bb593e00 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -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;
--
2.25.1
More information about the wine-devel
mailing list