Skip to content

Commit 103315a

Browse files
committed
Add support for mut in the fuzz_target! macro
1 parent 9848925 commit 103315a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Released YYYY-MM-DD.
66

77
* Bindings to `LLVMFuzzerCustomCrossOver` through the `fuzz_crossover` macro.
88
* `example_crossover` using both `fuzz_mutator` and `fuzz_crossover` (adapted from @rigtorp)
9+
* Support for `mut` in the `fuzz_target!` macro.
910

1011
### Changed
1112

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
203203
/// `"arbitrary-derive"` cargo feature.
204204
#[macro_export]
205205
macro_rules! fuzz_target {
206-
(|$bytes:ident| $body:expr) => {
206+
(|$bytes:pat_param| $body:expr) => {
207207
const _: () = {
208208
/// Auto-generated function
209209
#[no_mangle]
@@ -249,10 +249,18 @@ macro_rules! fuzz_target {
249249
$crate::fuzz_target!(|$data| $body);
250250
};
251251

252+
(|mut $data:ident: &[u8]| $body:expr) => {
253+
$crate::fuzz_target!(|mut $data| $body);
254+
};
255+
252256
(|$data:ident: $dty:ty| $body:expr) => {
253257
$crate::fuzz_target!(|$data: $dty| -> () { $body });
254258
};
255259

260+
(|mut $data:ident: $dty:ty| $body:expr) => {
261+
$crate::fuzz_target!(|mut $data: $dty| -> () { $body });
262+
};
263+
256264
(|$data:ident: $dty:ty| -> $rty:ty $body:block) => {
257265
const _: () = {
258266
/// Auto-generated function

0 commit comments

Comments
 (0)