Mesa (staging/20.1): util/ra: Sanity check that we're adding a valid reg to a class.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 29 21:20:09 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: a1de267a21acacc4c77bbb94127bfbf1caa4bfc8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1de267a21acacc4c77bbb94127bfbf1caa4bfc8

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Apr  9 15:10:08 2020 -0700

util/ra: Sanity check that we're adding a valid reg to a class.

BITSET_SET might not segfault on you right away if you're just slightly
off, and an assert is nicer anyway.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4537>

---

 src/util/register_allocate.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index a65b5ea154f..68d4a13ca1e 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -371,6 +371,8 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
 {
    struct ra_class *class = regs->classes[c];
 
+   assert(r < regs->count);
+
    BITSET_SET(class->regs, r);
    class->p++;
 }



More information about the mesa-commit mailing list