From 0ddeb3b824dcabc2b3a99feb0be036782fa56fee Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Tue, 1 Jan 2019 12:10:21 +0000 Subject: Fix the same bug as #396 but for bytes too --- crates/ra_syntax/src/validation/byte.rs | 4 +++- crates/ra_syntax/tests/data/parser/fuzz-failures/0004.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 crates/ra_syntax/tests/data/parser/fuzz-failures/0004.rs (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/validation/byte.rs b/crates/ra_syntax/src/validation/byte.rs index d0897eeed..714224b09 100644 --- a/crates/ra_syntax/src/validation/byte.rs +++ b/crates/ra_syntax/src/validation/byte.rs @@ -88,7 +88,9 @@ fn validate_byte_escape(text: &str, range: TextRange, errors: &mut Vec) { // A ByteCodeEscape has 4 chars, example: `\xDD` - if text.len() < 4 { + if !text.is_ascii() { + errors.push(SyntaxError::new(MalformedByteCodeEscape, range)); + } else if text.chars().count() < 4 { errors.push(SyntaxError::new(TooShortByteCodeEscape, range)); } else { assert!( diff --git a/crates/ra_syntax/tests/data/parser/fuzz-failures/0004.rs b/crates/ra_syntax/tests/data/parser/fuzz-failures/0004.rs new file mode 100644 index 000000000..003290f52 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/fuzz-failures/0004.rs @@ -0,0 +1 @@ +b"\xʿ \ No newline at end of file -- cgit v1.2.3