diff options
| author | Wade Mealing <wmealing@gmail.com> | 2011-09-28 04:15:24 +1000 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-27 23:20:31 -0700 |
| commit | f375391cb61bb0a06f3e2fe80aac070ea4c83fc1 (patch) | |
| tree | c93cda5736b54f696dcc3f075e23771867487667 /src/comp/syntax/parse | |
| parent | a96b16e8c334abb422d85cbd79a15afbe9efc4d1 (diff) | |
| download | rust-f375391cb61bb0a06f3e2fe80aac070ea4c83fc1.tar.gz rust-f375391cb61bb0a06f3e2fe80aac070ea4c83fc1.zip | |
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.
Diffstat (limited to 'src/comp/syntax/parse')
| -rw-r--r-- | src/comp/syntax/parse/lexer.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index e36b26c559e..f10701ceba5 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -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 { |
