@@ -6,21 +6,21 @@ extern "C" {
6
6
fn rust_fuzzer_test_input ( input : & [ u8 ] ) ;
7
7
}
8
8
9
- #[ export_name= "LLVMFuzzerTestOneInput" ]
9
+ #[ export_name = "LLVMFuzzerTestOneInput" ]
10
10
pub fn test_input_wrap ( data : * const u8 , size : usize ) -> i32 {
11
- :: std:: panic:: catch_unwind ( || unsafe {
11
+ let test_input = :: std:: panic:: catch_unwind ( || unsafe {
12
12
let data_slice = :: std:: slice:: from_raw_parts ( data, size) ;
13
13
rust_fuzzer_test_input ( data_slice) ;
14
- } )
15
- . err ( ) . map ( |_|
14
+ } ) ;
15
+ if test_input . err ( ) . is_some ( ) {
16
16
// hopefully the custom panic hook will be called before and abort the
17
17
// process before the stack frames are unwinded.
18
- :: std:: process:: abort ( )
19
- ) ;
18
+ :: std:: process:: abort ( ) ;
19
+ }
20
20
0
21
21
}
22
22
23
- #[ export_name= "LLVMFuzzerInitialize" ]
23
+ #[ export_name = "LLVMFuzzerInitialize" ]
24
24
pub fn initialize ( _argc : * const isize , _argv : * const * const * const u8 ) -> isize {
25
25
// Registers a panic hook that aborts the process before unwinding.
26
26
// It is useful to abort before unwinding so that the fuzzer will then be
@@ -31,7 +31,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
31
31
// We will be able to remove this code when
32
32
// https://github.com/rust-lang/cargo/issues/5423 is fixed.
33
33
:: std:: panic:: set_hook ( Box :: new ( |_| {
34
- :: std:: process:: abort ( ) ;
34
+ :: std:: process:: abort ( ) ;
35
35
} ) ) ;
36
36
0
37
37
}
@@ -40,7 +40,7 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize
40
40
macro_rules! fuzz_target {
41
41
( |$bytes: ident| $body: block) => {
42
42
#[ no_mangle]
43
- pub extern fn rust_fuzzer_test_input( $bytes: & [ u8 ] ) {
43
+ pub extern "C" fn rust_fuzzer_test_input( $bytes: & [ u8 ] ) {
44
44
$body
45
45
}
46
46
} ;
@@ -49,7 +49,7 @@ macro_rules! fuzz_target {
49
49
} ;
50
50
( |$data: ident: $dty: ty| $body: block) => {
51
51
#[ no_mangle]
52
- pub extern fn rust_fuzzer_test_input( bytes: & [ u8 ] ) {
52
+ pub extern "C" fn rust_fuzzer_test_input( bytes: & [ u8 ] ) {
53
53
use libfuzzer_sys:: arbitrary:: { Arbitrary , RingBuffer } ;
54
54
55
55
let mut buf = match RingBuffer :: new( bytes, bytes. len( ) ) {
0 commit comments