@@ -185,7 +185,7 @@ const Fuzzer = struct {
185
185
if (f .recent_cases .entries .len == 0 ) {
186
186
// Prepare initial input.
187
187
try f .recent_cases .ensureUnusedCapacity (gpa , 100 );
188
- const len = rng .uintLessThanBiased (usize , 80 );
188
+ const len = rng .intRangeAtMostBiased (usize , f . min_len , f . max_len );
189
189
try f .input .resize (gpa , len );
190
190
rng .bytes (f .input .items );
191
191
f .recent_cases .putAssumeCapacity (.{
@@ -272,7 +272,7 @@ const Fuzzer = struct {
272
272
const rng = fuzzer .rng .random ();
273
273
274
274
if (f .input .items .len == 0 ) {
275
- const len = rng .uintLessThanBiased (usize , 80 );
275
+ const len = rng .intRangeAtMostBiased (usize , f . min_len , f . max_len );
276
276
try f .input .resize (gpa , len );
277
277
rng .bytes (f .input .items );
278
278
return ;
@@ -288,6 +288,9 @@ const Fuzzer = struct {
288
288
} else {
289
289
unreachable ;
290
290
}
291
+
292
+ assert (f .input .items .len >= f .min_len );
293
+ assert (f .input .items .len <= f .max_len );
291
294
}
292
295
};
293
296
@@ -308,6 +311,8 @@ var fuzzer: Fuzzer = .{
308
311
.deduplicated_runs = 0 ,
309
312
.recent_cases = .{},
310
313
.coverage = undefined ,
314
+ .min_len = 0 ,
315
+ .max_len = 80 ,
311
316
};
312
317
313
318
export fn fuzzer_next () Fuzzer.Slice {
0 commit comments