Mesa (master): gallivm/nir: don't access stream var outside bounds
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 7 20:37:18 UTC 2020
Module: Mesa
Branch: master
Commit: 690238ff564ecb4f9dcfdfd61a9c36a8447cc863
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=690238ff564ecb4f9dcfdfd61a9c36a8447cc863
Author: Dave Airlie <airlied at redhat.com>
Date: Fri Jun 19 16:18:22 2020 +1000
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 <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5555>
---
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], "");
More information about the mesa-commit
mailing list