mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
fuzzing: fix off-by-one in limit count
This commit is contained in:
parent
98253bc0ee
commit
2da8ec9865
1 changed files with 42 additions and 42 deletions
|
|
@ -512,7 +512,7 @@ const Fuzzer = struct {
|
||||||
self.corpus_pos = 0;
|
self.corpus_pos = 0;
|
||||||
|
|
||||||
const rng = self.rng.random();
|
const rng = self.rng.random();
|
||||||
while (true) {
|
const m = while (true) {
|
||||||
const m = self.mutations.items[rng.uintLessThanBiased(usize, self.mutations.items.len)];
|
const m = self.mutations.items[rng.uintLessThanBiased(usize, self.mutations.items.len)];
|
||||||
if (!m.mutate(
|
if (!m.mutate(
|
||||||
rng,
|
rng,
|
||||||
|
|
@ -524,8 +524,11 @@ const Fuzzer = struct {
|
||||||
inst.const_vals8.items,
|
inst.const_vals8.items,
|
||||||
inst.const_vals16.items,
|
inst.const_vals16.items,
|
||||||
)) continue;
|
)) continue;
|
||||||
|
break m;
|
||||||
|
};
|
||||||
|
|
||||||
self.run();
|
self.run();
|
||||||
|
|
||||||
if (inst.isFresh()) {
|
if (inst.isFresh()) {
|
||||||
@branchHint(.unlikely);
|
@branchHint(.unlikely);
|
||||||
|
|
||||||
|
|
@ -569,9 +572,6 @@ const Fuzzer = struct {
|
||||||
);
|
);
|
||||||
self.corpus_dir_idx += 1;
|
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 {
|
export fn fuzzer_main(limit_kind: abi.LimitKind, amount: u64) void {
|
||||||
switch (limit_kind) {
|
switch (limit_kind) {
|
||||||
.forever => while (true) fuzzer.cycle(),
|
.forever => while (true) fuzzer.cycle(),
|
||||||
.iterations => for (0..amount -| 1) |_| fuzzer.cycle(),
|
.iterations => for (0..amount) |_| fuzzer.cycle(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue