@@ -4,14 +4,14 @@ extern crate libfuzzer_sys;
44
55use anyhow:: Result ;
66use arbitrary:: Arbitrary ;
7- use bstr:: { BStr , BString } ;
7+ use bstr:: BStr ;
88use gix_config_value:: {
99 color:: { Attribute , Name } ,
1010 path:: interpolate:: Context ,
1111 Boolean , Color , Integer , Path ,
1212} ;
1313use 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 } ;
1515
1616#[ derive( Debug , Arbitrary ) ]
1717struct Ctx < ' a > {
@@ -29,16 +29,17 @@ fn fuzz(ctx: Ctx) -> Result<()> {
2929
3030 _ = black_box ( Color :: try_from ( BStr :: new ( ctx. color_str ) ) ) ?;
3131
32+ let mut buf = String :: with_capacity ( 128 ) ;
3233 let a = Attribute :: from_str ( ctx. attribute_str ) ?;
33- _ = black_box ( format ! ( "{a}" ) ) ;
34+ _ = black_box ( write ! ( & mut buf , "{a}" ) ) ;
3435
3536 let name = Name :: from_str ( ctx. name_str ) ?;
36- _ = black_box ( format ! ( "{name}" ) ) ;
37+ _ = black_box ( write ! ( & mut buf , "{name}" ) ) ;
3738
3839 let i = Integer :: try_from ( BStr :: new ( ctx. integer_str ) ) ?;
3940 _ = black_box ( i. to_decimal ( ) ) ;
4041
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 ) ) ) ;
4243 _ = black_box ( p. interpolate ( Context :: default ( ) ) ) ;
4344
4445 Ok ( ( ) )
0 commit comments