File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -904,7 +904,13 @@ fn cooked_byte(input: Cursor) -> PResult<()> {
904904 } ;
905905 if ok {
906906 match bytes. next ( ) {
907- Some ( ( offset, _) ) => Ok ( ( input. advance ( offset) , ( ) ) ) ,
907+ Some ( ( offset, _) ) => {
908+ if input. chars ( ) . as_str ( ) . is_char_boundary ( offset) {
909+ Ok ( ( input. advance ( offset) , ( ) ) )
910+ } else {
911+ Err ( LexError )
912+ }
913+ }
908914 None => Ok ( ( input. advance ( input. len ( ) ) , ( ) ) ) ,
909915 }
910916 } else {
Original file line number Diff line number Diff line change 11extern crate proc_macro2;
22
3+ use std:: str;
4+
35use proc_macro2:: { Term , Literal , TokenStream } ;
46
57#[ cfg( procmacro2_semver_exempt) ]
@@ -161,3 +163,10 @@ fn span_join() {
161163
162164 assert_eq ! ( joined1. unwrap( ) . source_file( ) , source1[ 0 ] . span. source_file( ) ) ;
163165}
166+
167+ #[ test]
168+ fn no_panic ( ) {
169+ let s = str:: from_utf8 ( b"b\' \xc2 \x86 \x00 \x00 \x00 ^\" " ) . unwrap ( ) ;
170+ assert ! ( s. parse:: <proc_macro2:: TokenStream >( ) . is_err( ) ) ;
171+ }
172+
You can’t perform that action at this time.
0 commit comments