i965/fs: fix uninitialized memory access
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 16 Feb 2017 13:06:07 +0000 (13:06 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 17 Feb 2017 10:07:56 +0000 (10:07 +0000)
Found while running shader-db under valgrind.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Cc: "13.0 17.0" <mesa-stable@lists.freedesktop.org>
src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp

index f56f05b7e9b5607e720cde6e54a3471ceb9daf0d..952276faed8000abef92cb8aa9972c561c1c537b 100644 (file)
@@ -207,9 +207,8 @@ fs_visitor::register_coalesce()
             channels_remaining = -1;
             continue;
          }
-         dst_reg_offset[offset] = inst->dst.offset / REG_SIZE;
-         if (inst->size_written > REG_SIZE)
-            dst_reg_offset[offset + 1] = inst->dst.offset / REG_SIZE + 1;
+         for (unsigned i = 0; i < MAX2(inst->size_written / REG_SIZE, 1); i++)
+            dst_reg_offset[offset + i] = inst->dst.offset / REG_SIZE + i;
          mov[offset] = inst;
          channels_remaining -= regs_written(inst);
       }