@@ -1423,29 +1423,31 @@ Lexer::parse_partial_hex_escape ()
1423
1423
char hexNum[3 ] = {0 , 0 , 0 };
1424
1424
1425
1425
// first hex char
1426
- skip_input ();
1427
- current_char = peek_input ();
1426
+ current_char = peek_input (1 );
1428
1427
int additional_length_offset = 1 ;
1429
1428
1430
1429
if (!is_x_digit (current_char))
1431
1430
{
1432
1431
rust_error_at (get_current_location (),
1433
1432
" invalid character %<\\ x%c%> in \\ x sequence" ,
1434
1433
current_char);
1434
+ return std::make_pair (0 , 0 );
1435
1435
}
1436
1436
hexNum[0 ] = current_char;
1437
1437
1438
1438
// second hex char
1439
1439
skip_input ();
1440
- current_char = peek_input ();
1440
+ current_char = peek_input (1 );
1441
1441
additional_length_offset++;
1442
1442
1443
1443
if (!is_x_digit (current_char))
1444
1444
{
1445
1445
rust_error_at (get_current_location (),
1446
- " invalid character %<\\ x%c%> in \\ x sequence" ,
1446
+ " invalid character %<\\ x%c%c% > in \\ x sequence" , hexNum[ 0 ] ,
1447
1447
current_char);
1448
+ return std::make_pair (0 , 1 );
1448
1449
}
1450
+ skip_input ();
1449
1451
hexNum[1 ] = current_char;
1450
1452
1451
1453
long hexLong = std::strtol (hexNum, nullptr , 16 );
@@ -1627,7 +1629,7 @@ Lexer::parse_byte_string (Location loc)
1627
1629
else
1628
1630
length += std::get<1 > (escape_length_pair);
1629
1631
1630
- if (output_char != 0 )
1632
+ if (output_char != 0 || !std::get< 2 > (escape_length_pair) )
1631
1633
str += output_char;
1632
1634
1633
1635
continue ;
@@ -1722,6 +1724,14 @@ Lexer::parse_raw_byte_string (Location loc)
1722
1724
}
1723
1725
}
1724
1726
1727
+ if ((unsigned char ) current_char > 127 )
1728
+ {
1729
+ rust_error_at (get_current_location (),
1730
+ " character %<%c%> in raw byte string out of range" ,
1731
+ current_char);
1732
+ current_char = 0 ;
1733
+ }
1734
+
1725
1735
length++;
1726
1736
1727
1737
str += current_char;
0 commit comments