diff options
author | George Barrett <bob@bob131.so> | 2017-11-19 21:55:10 +1100 |
---|---|---|
committer | Andres Gomez <agomez@igalia.com> | 2017-11-22 18:41:23 +0200 |
commit | ae629ca8054a55bc4808c06aba1851174a7a42fe (patch) | |
tree | de320f4c291fb4242a787ea5984198275b418230 | |
parent | a4456581781de64beaf5928d1f18a91efbb824e3 (diff) | |
download | mesa-ae629ca8054a55bc4808c06aba1851174a7a42fe.tar.gz |
glsl: Catch subscripted calls to undeclared subroutines
generate_array_index fails to check whether the target of a subroutine
call exists in the AST, potentially passing around null ir_rvalue
pointers eventuating in abort/segfault.
Fixes: fd01840c0bd3 ("glsl: add AoA support to subroutines")
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100438
(cherry picked from commit f09c2cefdd53cd61562a994294e9d0630868d2da)
-rw-r--r-- | src/compiler/glsl/ast_function.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index 2d156ae1da1..8c74c583d7f 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -663,8 +663,13 @@ generate_array_index(void *mem_ctx, exec_list *instructions, ir_variable *sub_var = NULL; *function_name = array->primary_expression.identifier; - match_subroutine_by_name(*function_name, actual_parameters, - state, &sub_var); + if (!match_subroutine_by_name(*function_name, actual_parameters, + state, &sub_var)) { + _mesa_glsl_error(&loc, state, "Unknown subroutine `%s'", + *function_name); + *function_name = NULL; /* indicate error condition to caller */ + return NULL; + } ir_rvalue *outer_array_idx = idx->hir(instructions, state); return new(mem_ctx) ir_dereference_array(sub_var, outer_array_idx); |