mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
fuzzing: fix off-by-one in limit count
This commit is contained in:
parent
98253bc0ee
commit
2da8ec9865
@ -512,7 +512,7 @@ const Fuzzer = struct {
|
||||
self.corpus_pos = 0;
|
||||
|
||||
const rng = self.rng.random();
|
||||
while (true) {
|
||||
const m = while (true) {
|
||||
const m = self.mutations.items[rng.uintLessThanBiased(usize, self.mutations.items.len)];
|
||||
if (!m.mutate(
|
||||
rng,
|
||||
@ -524,8 +524,11 @@ const Fuzzer = struct {
|
||||
inst.const_vals8.items,
|
||||
inst.const_vals16.items,
|
||||
)) continue;
|
||||
break m;
|
||||
};
|
||||
|
||||
self.run();
|
||||
|
||||
if (inst.isFresh()) {
|
||||
@branchHint(.unlikely);
|
||||
|
||||
@ -569,9 +572,6 @@ const Fuzzer = struct {
|
||||
);
|
||||
self.corpus_dir_idx += 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -618,7 +618,7 @@ export fn fuzzer_new_input(bytes: abi.Slice) void {
|
||||
export fn fuzzer_main(limit_kind: abi.LimitKind, amount: u64) void {
|
||||
switch (limit_kind) {
|
||||
.forever => while (true) fuzzer.cycle(),
|
||||
.iterations => for (0..amount -| 1) |_| fuzzer.cycle(),
|
||||
.iterations => for (0..amount) |_| fuzzer.cycle(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user