From fc3951cfde692b682ae0a79502cd7ba3b77a68d7 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 13 Feb 2026 10:58:42 -0500 Subject: [PATCH] util/bitset: add an assert for big BITSET_EXTRACT This just bit me. Add an assert to catch the next person who doesn't read the function signature and tries to extract 64-bits out and wonders why things are silently broken. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Adam Jackson Part-of: --- src/util/bitset.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/bitset.h b/src/util/bitset.h index 3c90a2aaf19..bc324bc435f 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -282,6 +282,7 @@ __bitset_clear_range(BITSET_WORD *r, int start, int end) static inline unsigned __bitset_extract(const BITSET_WORD *r, unsigned start, unsigned count) { + assert(count <= BITSET_WORDBITS); unsigned shift = start % BITSET_WORDBITS; BITSET_WORD lower = r[BITSET_BITWORD(start)] >> shift; BITSET_WORD upper = shift ? r[BITSET_BITWORD(start + count - 1)] << (BITSET_WORDBITS - shift) : 0;