Skip to content

Commit

Permalink
Add support for mut in the fuzz_target! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ventaquil committed Mar 23, 2024
1 parent 9848925 commit 103315a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Released YYYY-MM-DD.

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

### Changed

Expand Down
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
/// `"arbitrary-derive"` cargo feature.
#[macro_export]
macro_rules! fuzz_target {
(|$bytes:ident| $body:expr) => {
(|$bytes:pat_param| $body:expr) => {
const _: () = {
/// Auto-generated function
#[no_mangle]
Expand Down Expand Up @@ -249,10 +249,18 @@ macro_rules! fuzz_target {
$crate::fuzz_target!(|$data| $body);
};

(|mut $data:ident: &[u8]| $body:expr) => {
$crate::fuzz_target!(|mut $data| $body);
};

(|$data:ident: $dty:ty| $body:expr) => {
$crate::fuzz_target!(|$data: $dty| -> () { $body });
};

(|mut $data:ident: $dty:ty| $body:expr) => {
$crate::fuzz_target!(|mut $data: $dty| -> () { $body });
};

(|$data:ident: $dty:ty| -> $rty:ty $body:block) => {
const _: () = {
/// Auto-generated function
Expand Down

0 comments on commit 103315a

Please sign in to comment.