diff options
author | Anuj Phogat <[email protected]> | 2014-09-18 16:30:31 -0700 |
---|---|---|
committer | Anuj Phogat <[email protected]> | 2014-10-22 16:13:37 -0700 |
commit | 6f0089e92e9a3b096b978bb09a87db6a38acb7b2 (patch) | |
tree | 32e9cae1c76ec629753b54d898f2544460324c02 /src | |
parent | 8ec40adf7eaaf4a107ee76497d69d1479580f711 (diff) |
glsl: Fix crash due to negative array index
Currently Mesa crashes with a shader like this:
[fragmnet shader]
float[5] array;
int idx = -2;
void main()
{
gl_FragColor = vec4(0.0, 1.0, 0.0, array[idx]);
}
Cc: <[email protected]>
Signed-off-by: Anuj Phogat <[email protected]>
Reviewed-by: Chris Forbes <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/opt_array_splitting.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/glsl/opt_array_splitting.cpp b/src/glsl/opt_array_splitting.cpp index ebb076b223e..9e73f3c44bb 100644 --- a/src/glsl/opt_array_splitting.cpp +++ b/src/glsl/opt_array_splitting.cpp @@ -295,7 +295,7 @@ ir_array_splitting_visitor::split_deref(ir_dereference **deref) ir_constant *constant = deref_array->array_index->as_constant(); assert(constant); - if (constant->value.i[0] < (int)entry->size) { + if (constant->value.i[0] >= 0 && constant->value.i[0] < (int)entry->size) { *deref = new(entry->mem_ctx) ir_dereference_variable(entry->components[constant->value.i[0]]); } else { |