index bf512cf806ff7784d341a18e771e32e2a8f146cd..b4ecf0b0390179481e3aad8228294d4e45c126dc 100644 (file)
@@ -1343,7 +1343,7 @@ bms_next_member(const Bitmapset *a, int prevbit)
*
* Returns largest member less than "prevbit", or -2 if there is none.
* "prevbit" must NOT be more than one above the highest possible bit that can
- * be set at the Bitmapset at its current size.
+ * be set in the Bitmapset at its current size.
*
* To ease finding the highest set bit for the initial loop, the special
* prevbit value of -1 can be passed to have the function find the highest
if (a == NULL || prevbit == 0)
return -2;
+ /* Validate callers didn't give us something out of range */
+ Assert(prevbit <= a->nwords * BITS_PER_BITMAPWORD);
+ Assert(prevbit >= -1);
+
/* transform -1 to the highest possible bit we could have set */
if (prevbit == -1)
prevbit = a->nwords * BITS_PER_BITMAPWORD - 1;