glsl: Explicitly NULL-check variables before making a dereference.
The constructor currently returns a ir_dereference_variable of error type when provided NULL, but that's about to change in the next commit. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
2cd652f810
commit
dca19a7711
|
@ -1692,14 +1692,14 @@ ast_expression::hir(exec_list *instructions,
|
||||||
ir_variable *var =
|
ir_variable *var =
|
||||||
state->symbols->get_variable(this->primary_expression.identifier);
|
state->symbols->get_variable(this->primary_expression.identifier);
|
||||||
|
|
||||||
result = new(ctx) ir_dereference_variable(var);
|
|
||||||
|
|
||||||
if (var != NULL) {
|
if (var != NULL) {
|
||||||
var->used = true;
|
var->used = true;
|
||||||
|
result = new(ctx) ir_dereference_variable(var);
|
||||||
} else {
|
} else {
|
||||||
_mesa_glsl_error(& loc, state, "`%s' undeclared",
|
_mesa_glsl_error(& loc, state, "`%s' undeclared",
|
||||||
this->primary_expression.identifier);
|
this->primary_expression.identifier);
|
||||||
|
|
||||||
|
result = ir_call::get_error_instruction(ctx);
|
||||||
error_emitted = true;
|
error_emitted = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue