mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 01:30:08 +01:00
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: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
This commit is contained in:
parent
8ec40adf7e
commit
6f0089e92e
1 changed files with 1 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue