About Social Code
aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2021-01-14 14:46:17 -0800
committerMarge Bot <eric+marge@anholt.net>2021-01-25 18:50:26 +0000
commitb183b6ddd7ffb07ebaa1ee11dc99a91b16e97315 (patch)
tree2151c19986d5421c1695c7b9dd441eabdf2052f8 /src/util
parentefff70e73ff6fbb1f73ace016c8eb53920629fe8 (diff)
util/bitset: Avoid dereferencing the bitset for size == 0.
If we don't have any bits in our set, don't go reading the pointer. Fixes invalid accesses caught by ASan in liveness and nir_to_tgsi when impl->ssa_alloc == 0. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8530>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/bitset.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util/bitset.h b/src/util/bitset.h
index dd9a8bebae3..5313f85fcee 100644
--- a/src/util/bitset.h
+++ b/src/util/bitset.h
@@ -151,7 +151,7 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp,
* @param __size number of bits in the set to consider
*/
#define BITSET_FOREACH_SET(__i, __set, __size) \
- for (BITSET_WORD __tmp = *(__set), *__foo = &__tmp; __foo != NULL; __foo = NULL) \
+ for (BITSET_WORD __tmp = (__size) == 0 ? 0 : *(__set), *__foo = &__tmp; __foo != NULL; __foo = NULL) \
for (__i = 0; \
(__i = __bitset_next_set(__i, &__tmp, __set, __size)) < __size;)