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
|
@ -490,8 +490,15 @@ fn next_token_inner(rdr: reader) -> token::token {
|
||||||
ret token::LIT_CHAR(c2);
|
ret token::LIT_CHAR(c2);
|
||||||
}
|
}
|
||||||
'"' {
|
'"' {
|
||||||
|
let n = rdr.get_chpos();
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
while rdr.curr() != '"' {
|
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();
|
let ch = rdr.curr();
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
alt ch {
|
alt ch {
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// -*- rust -*-
|
||||||
|
|
||||||
|
// error-pattern: unterminated double quote string
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
"
|
||||||
|
}
|
Loading…
Reference in New Issue