11#![ no_main]
2- #[ macro_use] extern crate libfuzzer_sys;
2+ #[ macro_use]
3+ extern crate libfuzzer_sys;
34extern crate ed_diff;
45
56use std:: fs:: { self , File } ;
@@ -11,16 +12,24 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
1112 from. push( b'\n' ) ;
1213 to. push( b'\n' ) ;
1314 if let Ok ( s) = String :: from_utf8( from. clone( ) ) {
14- if !s. is_ascii( ) { return }
15- if s. find( |x| x < ' ' && x != '\n' ) . is_some( ) { return }
15+ if !s. is_ascii( ) {
16+ return ;
17+ }
18+ if s. find( |x| x < ' ' && x != '\n' ) . is_some( ) {
19+ return ;
20+ }
1621 } else {
17- return
22+ return ;
1823 }
1924 if let Ok ( s) = String :: from_utf8( to. clone( ) ) {
20- if !s. is_ascii( ) { return }
21- if s. find( |x| x < ' ' && x != '\n' ) . is_some( ) { return }
25+ if !s. is_ascii( ) {
26+ return ;
27+ }
28+ if s. find( |x| x < ' ' && x != '\n' ) . is_some( ) {
29+ return ;
30+ }
2231 } else {
23- return
32+ return ;
2433 }
2534 let diff = ed_diff:: diff_w( & from, & to, "target/fuzz.file" ) . unwrap( ) ;
2635 File :: create( "target/fuzz.file.original" )
@@ -45,11 +54,18 @@ fuzz_target!(|x: (Vec<u8>, Vec<u8>)| {
4554 . output( )
4655 . unwrap( ) ;
4756 if !output. status. success( ) {
48- panic!( "STDOUT:\n {}\n STDERR:\n {}" , String :: from_utf8_lossy( & output. stdout) , String :: from_utf8_lossy( & output. stderr) ) ;
57+ panic!(
58+ "STDOUT:\n {}\n STDERR:\n {}" ,
59+ String :: from_utf8_lossy( & output. stdout) ,
60+ String :: from_utf8_lossy( & output. stderr)
61+ ) ;
4962 }
5063 let result = fs:: read( "target/fuzz.file" ) . unwrap( ) ;
5164 if result != to {
52- panic!( "STDOUT:\n {}\n STDERR:\n {}" , String :: from_utf8_lossy( & output. stdout) , String :: from_utf8_lossy( & output. stderr) ) ;
65+ panic!(
66+ "STDOUT:\n {}\n STDERR:\n {}" ,
67+ String :: from_utf8_lossy( & output. stdout) ,
68+ String :: from_utf8_lossy( & output. stderr)
69+ ) ;
5370 }
5471} ) ;
55-
0 commit comments