Patch to error instead of crashing when parsing unmatched double quotes
Patch to error and fail instead of using all available memory then crashing to detect the error condition of an unmatched double quote before the end of a file. I couldn't get it to show nice error messages, so this may not be the ideal fix. A test case for this situation has also been added.
This commit is contained in:
parent
a96b16e8c3
commit
f375391cb6
src
@ -490,8 +490,15 @@ fn next_token_inner(rdr: reader) -> token::token {
|
||||
ret token::LIT_CHAR(c2);
|
||||
}
|
||||
'"' {
|
||||
let n = rdr.get_chpos();
|
||||
rdr.bump();
|
||||
while rdr.curr() != '"' {
|
||||
if rdr.is_eof() {
|
||||
rdr.err(#fmt["unterminated double quote string: %s",
|
||||
rdr.get_str_from(n)]);
|
||||
fail;
|
||||
}
|
||||
|
||||
let ch = rdr.curr();
|
||||
rdr.bump();
|
||||
alt ch {
|
||||
|
8
src/test/compile-fail/unbalanced-doublequote.rs
Normal file
8
src/test/compile-fail/unbalanced-doublequote.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// -*- rust -*-
|
||||
|
||||
// error-pattern: unterminated double quote string
|
||||
|
||||
|
||||
fn main() {
|
||||
"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user