Mesa (master): draw: (trivial) fix out-of-bounds vector initialization

Roland Scheidegger sroland at kemper.freedesktop.org
Wed May 6 14:52:22 UTC 2015


Module: Mesa
Branch: master
Commit: b8a1495106a8b70e9026b7798a5df2fb9737c55e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8a1495106a8b70e9026b7798a5df2fb9737c55e

Author: Roland Scheidegger <sroland at vmware.com>
Date:   Wed May  6 15:56:17 2015 +0200

draw: (trivial) fix out-of-bounds vector initialization

Was off-by-one. llvm says inserting an element with an index higher than the
number of elements yields undefined results. Previously such inserts were
ignored but as of llvm revision 235854 the vector gets replaced with undef,
causing failures.
This fixes piglit gl-3.2-layered-rendering-gl-layer, as mentioned in
https://llvm.org/bugs/show_bug.cgi?id=23424.

Reviewed-by: Brian Paul <brianp at vmware.com>
Cc: mesa-stable at lists.freedesktop.org

---

 src/gallium/auxiliary/draw/draw_llvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 7150611..b9e55af 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -2048,7 +2048,7 @@ generate_mask_value(struct draw_gs_llvm_variant *variant,
 
    num_prims = lp_build_broadcast(gallivm, lp_build_vec_type(gallivm, mask_type),
                                   variant->num_prims);
-   for (i = 0; i <= gs_type.length; i++) {
+   for (i = 0; i < gs_type.length; i++) {
       LLVMValueRef idx = lp_build_const_int32(gallivm, i);
       mask_val = LLVMBuildInsertElement(builder, mask_val, idx, idx, "");
    }




More information about the mesa-commit mailing list