Skip to content

Commit 4207faa

Browse files
committed
Fix overflow in delimiter_of_raw_string at end of input
1 parent cfa1524 commit 4207faa

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/parse.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -468,22 +468,20 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> {
468468
}
469469

470470
fn delimiter_of_raw_string(input: Cursor) -> PResult<&str> {
471-
let mut n = 0;
472471
for (i, byte) in input.bytes().enumerate() {
473472
match byte {
474473
b'"' => {
475-
n = i;
476-
break;
474+
if i > 255 {
475+
// https://github.com/rust-lang/rust/pull/95251
476+
return Err(Reject);
477+
}
478+
return Ok((input.advance(i + 1), &input.rest[..i]));
477479
}
478480
b'#' => {}
479-
_ => return Err(Reject),
481+
_ => break,
480482
}
481483
}
482-
if n > 255 {
483-
// https://github.com/rust-lang/rust/pull/95251
484-
return Err(Reject);
485-
}
486-
Ok((input.advance(n + 1), &input.rest[..n]))
484+
Err(Reject)
487485
}
488486

489487
fn raw_byte_string(input: Cursor) -> Result<Cursor, Reject> {

0 commit comments

Comments
 (0)