Mesa (master): i965/vs: Fix access beyond array bounds for non-GRF operands .

Eric Anholt anholt at kemper.freedesktop.org
Mon Sep 26 22:38:36 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Sep 23 13:52:47 2011 -0700

i965/vs: Fix access beyond array bounds for non-GRF operands.

Caught by valgrind.  I never saw a segfault from it (probably because
it's hard to have much more of any other file than GRF).

---

 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index e0b2d2a..a5f6f93 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -241,9 +241,6 @@ vec4_visitor::opt_copy_propagation()
        * optimizing out access to the copy result
        */
       for (int i = 2; i >= 0; i--) {
-	 int reg = (virtual_grf_reg_map[inst->src[i].reg] +
-		    inst->src[i].reg_offset);
-
 	 /* Copied values end up in GRFs, and we don't track reladdr
 	  * accesses.
 	  */
@@ -251,6 +248,9 @@ vec4_visitor::opt_copy_propagation()
 	     inst->src[i].reladdr)
 	    continue;
 
+	 int reg = (virtual_grf_reg_map[inst->src[i].reg] +
+		    inst->src[i].reg_offset);
+
 	 /* Find the regs that each swizzle component came from.
 	  */
 	 src_reg *values[4];




More information about the mesa-commit mailing list