st/glsl_to_tgsi: avoid iterating past the head of the instruction list

exec_node::get_prev() does not guard against going past the beginning
of the list, so we need to add explicit checks here.

Found by ASAN in piglit arb_shader_storage_buffer_object-rendering.

Cc: mesa-stable@lists.freedesktop.org

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 911391bd70)
This commit is contained in:
Nicolai Hähnle 2017-02-22 20:04:39 +01:00 committed by Emil Velikov
parent ea7711fc0f
commit e59e2c664f

View file

@ -3432,10 +3432,17 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir)
inst->resource = buffer;
if (access)
inst->buffer_access = access->value.u[0];
if (inst == this->instructions.get_head_raw())
break;
inst = (glsl_to_tgsi_instruction *)inst->get_prev();
if (inst->op == TGSI_OPCODE_UADD)
if (inst->op == TGSI_OPCODE_UADD) {
if (inst == this->instructions.get_head_raw())
break;
inst = (glsl_to_tgsi_instruction *)inst->get_prev();
} while (inst && inst->op == op && inst->resource.file == PROGRAM_UNDEFINED);
}
} while (inst->op == op && inst->resource.file == PROGRAM_UNDEFINED);
}
void