@@ -4,14 +4,14 @@ extern crate libfuzzer_sys;
4
4
5
5
use anyhow:: Result ;
6
6
use arbitrary:: Arbitrary ;
7
- use bstr:: { BStr , BString } ;
7
+ use bstr:: BStr ;
8
8
use gix_config_value:: {
9
9
color:: { Attribute , Name } ,
10
10
path:: interpolate:: Context ,
11
11
Boolean , Color , Integer , Path ,
12
12
} ;
13
13
use libfuzzer_sys:: fuzz_target;
14
- use std:: { borrow:: Cow , hint:: black_box, str:: FromStr } ;
14
+ use std:: { borrow:: Cow , fmt :: Write , hint:: black_box, str:: FromStr } ;
15
15
16
16
#[ derive( Debug , Arbitrary ) ]
17
17
struct Ctx < ' a > {
@@ -29,16 +29,17 @@ fn fuzz(ctx: Ctx) -> Result<()> {
29
29
30
30
_ = black_box ( Color :: try_from ( BStr :: new ( ctx. color_str ) ) ) ?;
31
31
32
+ let mut buf = String :: with_capacity ( 128 ) ;
32
33
let a = Attribute :: from_str ( ctx. attribute_str ) ?;
33
- _ = black_box ( format ! ( "{a}" ) ) ;
34
+ _ = black_box ( write ! ( & mut buf , "{a}" ) ) ;
34
35
35
36
let name = Name :: from_str ( ctx. name_str ) ?;
36
- _ = black_box ( format ! ( "{name}" ) ) ;
37
+ _ = black_box ( write ! ( & mut buf , "{name}" ) ) ;
37
38
38
39
let i = Integer :: try_from ( BStr :: new ( ctx. integer_str ) ) ?;
39
40
_ = black_box ( i. to_decimal ( ) ) ;
40
41
41
- let p = Path :: try_from ( Cow :: Owned ( BString :: from ( ctx. path_str ) ) ) ? ;
42
+ let p = Path :: from ( Cow :: Borrowed ( BStr :: new ( ctx. path_str ) ) ) ;
42
43
_ = black_box ( p. interpolate ( Context :: default ( ) ) ) ;
43
44
44
45
Ok ( ( ) )
0 commit comments