dcapwell commented on code in PR #264:
URL: https://github.com/apache/cassandra-accord/pull/264#discussion_r2620245313


##########
accord-core/src/main/java/accord/utils/SmallBitSet.java:
##########
@@ -40,29 +40,51 @@ public long bits()
         return bits;
     }
 
+    private static long bitSafe(int i)
+    {
+        validateIndex(i);
+        return bit(i);
+    }
+
+    private static void validateIndex(int i)
+    {
+        if (i >= 64 || i < 0)
+            throw new IndexOutOfBoundsException("Unable to access bit " + i + 
"; must be between 0 and 63");
+    }
+
+    @Override
     public boolean set(int i)
     {
-        long bit = bit(i);
+        long bit = bitSafe(i);
         boolean result = 0 == (bits & bit);
         bits |= bit;
         return result;
     }
 
     @Override
-    public void setRange(int from, int to)
+    public void setRange(int fromInclusive, int toExclusive)

Review Comment:
   `to` was exclusive but wouldn't work if you gave the last index as it would 
cause the bits to be `0`; found in fuzz testing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to