From 690238ff564ecb4f9dcfdfd61a9c36a8447cc863 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 19 Jun 2020 16:18:22 +1000 Subject: [PATCH] gallivm/nir: don't access stream var outside bounds Since we allocate only enough for streams we see, don't access out of bounds when streams are given Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c index a8b7d0dd86e..7da701f06d8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c @@ -1593,6 +1593,8 @@ static void emit_vertex(struct lp_build_nir_context *bld_base, uint32_t stream_i struct lp_build_nir_soa_context *bld = (struct lp_build_nir_soa_context *)bld_base; LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder; + if (stream_id >= bld->gs_vertex_streams) + return; assert(bld->gs_iface->emit_vertex); LLVMValueRef total_emitted_vertices_vec = LLVMBuildLoad(builder, bld->total_emitted_vertices_vec_ptr[stream_id], ""); @@ -1617,6 +1619,8 @@ end_primitive_masked(struct lp_build_nir_context * bld_base, struct lp_build_nir_soa_context *bld = (struct lp_build_nir_soa_context *)bld_base; LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder; + if (stream_id >= bld->gs_vertex_streams) + return; struct lp_build_context *uint_bld = &bld_base->uint_bld; LLVMValueRef emitted_vertices_vec = LLVMBuildLoad(builder, bld->emitted_vertices_vec_ptr[stream_id], ""); -- 2.30.2