From 58aab48ab294cdbea853b796f99f92e15b2570b5 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 1 Apr 2024 20:51:27 +0200 Subject: [PATCH] fuzz: also generate the empty string sometimes Inspired by #6167, #6175, and the observation that 'echo hello "" world | hd' outputs extra spaces. --- fuzz/fuzz_targets/fuzz_common.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_common.rs b/fuzz/fuzz_targets/fuzz_common.rs index cf56268d7..6c261cf81 100644 --- a/fuzz/fuzz_targets/fuzz_common.rs +++ b/fuzz/fuzz_targets/fuzz_common.rs @@ -374,7 +374,7 @@ pub fn generate_random_string(max_length: usize) -> String { let invalid_utf8 = [0xC3, 0x28]; // Invalid UTF-8 sequence let mut result = String::new(); - for _ in 0..rng.gen_range(1..=max_length) { + for _ in 0..rng.gen_range(0..=max_length) { if rng.gen_bool(0.9) { let ch = valid_utf8.choose(&mut rng).unwrap(); result.push(*ch);