File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ extern crate libfuzzer_sys;
16
16
use std:: str:: Chars ;
17
17
use std:: cell:: RefCell ;
18
18
use std:: rc:: Rc ;
19
- use unicode_normalization:: UnicodeNormalization ;
19
+ use unicode_normalization:: { char :: canonical_combining_class , UnicodeNormalization } ;
20
20
21
21
const MAX_NONSTARTERS : u32 = 30 ;
22
22
@@ -30,8 +30,13 @@ impl<'a> Iterator for Counter<'a> {
30
30
type Item = char ;
31
31
32
32
fn next ( & mut self ) -> Option < char > {
33
- * self . value . borrow_mut ( ) += 1 ;
34
- self . iter . next ( )
33
+ let next = self . iter . next ( ) ;
34
+ if let Some ( c) = next {
35
+ if canonical_combining_class ( c) != 0 {
36
+ * self . value . borrow_mut ( ) += 1 ;
37
+ }
38
+ }
39
+ next
35
40
}
36
41
}
37
42
@@ -41,9 +46,8 @@ fuzz_target!(|input: String| {
41
46
let mut value = Rc :: new( RefCell :: new( 0 ) ) ;
42
47
let counter = Counter { iter: stream_safe. chars( ) , value: Rc :: clone( & mut value) } ;
43
48
for _ in counter. nfc( ) {
44
- // Plus 2: one for the starter at the beginning of a sequence, and
45
- // one for a starter that begins the following sequence.
46
- assert!( * value. borrow( ) <= MAX_NONSTARTERS + 2 ) ;
49
+ // Plus 1: The iterator may consume a starter that begins the next sequence.
50
+ assert!( * value. borrow( ) <= MAX_NONSTARTERS + 1 ) ;
47
51
* value. borrow_mut( ) = 0 ;
48
52
}
49
53
} ) ;
You can’t perform that action at this time.
0 commit comments