Mesa (master): i965: Assert that the GL primitive isn't out of range.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Jun 23 19:48:48 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Jun 22 11:20:32 2015 -0700

i965: Assert that the GL primitive isn't out of range.

Coverity sees the if (mode >= BRW_PRIM_OFFSET (128)) test and assumes
that the else-branch might execute for mode to up 127, which out be out
of bounds.

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/mesa/drivers/dri/i965/brw_draw.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index a7164db..b91597a 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -92,8 +92,10 @@ get_hw_prim_for_gl_prim(int mode)
 {
    if (mode >= BRW_PRIM_OFFSET)
       return mode - BRW_PRIM_OFFSET;
-   else
+   else {
+      assert(mode < ARRAY_SIZE(prim_to_hw_prim));
       return prim_to_hw_prim[mode];
+   }
 }
 
 




More information about the mesa-commit mailing list