Chromium Code Reviews| Index: base/json/json_parser.cc |
| diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc |
| index 50c8921d9352cccc235adea6b17e846275635c46..731bb70a850882971622825e7df8dfb8c2accc25 100644 |
| --- a/base/json/json_parser.cc |
| +++ b/base/json/json_parser.cc |
| @@ -680,11 +680,7 @@ std::unique_ptr<Value> JSONParser::ConsumeNumber() { |
| end_index = index_; |
| // The optional fraction part. |
| - if (*pos_ == '.') { |
| - if (!CanConsume(1)) { |
| - ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| - return nullptr; |
| - } |
| + if (CanConsume(1) && *pos_ == '.') { |
| NextChar(); |
| if (!ReadInt(true)) { |
| ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| @@ -694,10 +690,19 @@ std::unique_ptr<Value> JSONParser::ConsumeNumber() { |
| } |
| // Optional exponent part. |
| - if (*pos_ == 'e' || *pos_ == 'E') { |
| + if (CanConsume(1) && (*pos_ == 'e' || *pos_ == 'E')) { |
| NextChar(); |
| - if (*pos_ == '-' || *pos_ == '+') |
| + if (!CanConsume(1)) { |
| + ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| + return nullptr; |
| + } |
| + if (*pos_ == '-' || *pos_ == '+') { |
| NextChar(); |
| + if (!CanConsume(1)) { |
|
dcheng
2017/02/24 22:38:17
Can this be handled by falling through to the Read
Robert Sesek
2017/02/24 23:01:29
Yup, done.
|
| + ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| + return nullptr; |
| + } |
| + } |
| if (!ReadInt(true)) { |
| ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| return nullptr; |