Skip to content

Commit 13eb44d

Browse files
committed
sanitize minValue and maxValue for maximize
1 parent 0031c45 commit 13eb44d

File tree

1 file changed

+10
-1
lines changed
  • src/main/java/com/code_intelligence/jazzer/api

1 file changed

+10
-1
lines changed

src/main/java/com/code_intelligence/jazzer/api/Jazzer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,16 @@ public static void maximize(long value, int id, long minValue, long maxValue) {
273273
return;
274274
}
275275

276-
int numCounters = (int) (maxValue - minValue + 1);
276+
if (maxValue < minValue) {
277+
throw new IllegalArgumentException("maxValue must be >= minValue");
278+
}
279+
long range = maxValue - minValue;
280+
if (range < 0 || range > (long) Integer.MAX_VALUE - 1) {
281+
throw new IllegalArgumentException(
282+
"Range too large: (maxValue - minValue + 1) must be <= Integer.MAX_VALUE");
283+
}
284+
285+
int numCounters = (int) (range + 1);
277286

278287
try {
279288
// Allocate counters (idempotent, validates numCounters > 0 and consistency)

0 commit comments

Comments
 (0)