Skip to content

Commit b186142

Browse files
authored
[sanitizer] Make CHECKs in bitvector more precise (NFC) (#94630)
These CHECKs are all checking indices, which must be strictly smaller than the size (otherwise they would go out of bounds).
1 parent 855af13 commit b186142

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_bitvector.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,23 @@ class TwoLevelBitVector {
321321
};
322322

323323
private:
324-
void check(uptr idx) const { CHECK_LE(idx, size()); }
324+
void check(uptr idx) const { CHECK_LT(idx, size()); }
325325

326326
uptr idx0(uptr idx) const {
327327
uptr res = idx / (BV::kSize * BV::kSize);
328-
CHECK_LE(res, kLevel1Size);
328+
CHECK_LT(res, kLevel1Size);
329329
return res;
330330
}
331331

332332
uptr idx1(uptr idx) const {
333333
uptr res = (idx / BV::kSize) % BV::kSize;
334-
CHECK_LE(res, BV::kSize);
334+
CHECK_LT(res, BV::kSize);
335335
return res;
336336
}
337337

338338
uptr idx2(uptr idx) const {
339339
uptr res = idx % BV::kSize;
340-
CHECK_LE(res, BV::kSize);
340+
CHECK_LT(res, BV::kSize);
341341
return res;
342342
}
343343

0 commit comments

Comments
 (0)