tgsi: fix coverity out-of-bounds warning
authorRob Clark <robclark@freedesktop.org>
Thu, 26 May 2016 15:11:32 +0000 (11:11 -0400)
committerRob Clark <robclark@freedesktop.org>
Thu, 26 May 2016 19:17:49 +0000 (15:17 -0400)
CID 1271532 (#1 of 1): Out-of-bounds read (OVERRUN)34. overrun-local:
Overrunning array of 2 16-byte elements at element index 2 (byte offset
32) by dereferencing pointer &inst.Dst[i].

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/tgsi/tgsi_text.c

index 955d04234ef2bcfb1ca0e55e831455bb8eb63e74..8bdec0685ec78985f533c4cad42063cb2c24faca 100644 (file)
@@ -1081,6 +1081,9 @@ parse_instruction(
       inst.Memory.Qualifier = 0;
    }
 
+   assume(info->num_dst <= TGSI_FULL_MAX_DST_REGISTERS);
+   assume(info->num_src <= TGSI_FULL_MAX_SRC_REGISTERS);
+
    /* Parse instruction operands.
     */
    for (i = 0; i < info->num_dst + info->num_src + info->is_tex; i++) {