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..b94136979851cd7af114c6b25a1b980436d6daa5 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,15 @@ 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)) { |
|
dcheng
2017/02/24 23:05:33
In theory, we don't need 696-697, and we can fold
Robert Sesek
2017/02/24 23:07:21
Yeah, I agree that this is easier to read than fol
|
| + ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| + return nullptr; |
| + } |
| + if (*pos_ == '-' || *pos_ == '+') { |
| NextChar(); |
| + } |
| if (!ReadInt(true)) { |
| ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
| return nullptr; |