Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: base/json/json_parser.cc

Issue 12476030: Handle block comments ending in **/ in the JSON parser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: neater fix Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/json/json_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_parser.cc
diff --git a/base/json/json_parser.cc b/base/json/json_parser.cc
index 8442b012bcb698a1bab52d34f045290283ac083a..cc669f4779836bc1f71af323714f72325b6035a1 100644
--- a/base/json/json_parser.cc
+++ b/base/json/json_parser.cc
@@ -435,15 +435,18 @@ bool JSONParser::EatComment() {
return true;
}
} else if (next_char == '*') {
+ char previous_char = '\0';
// Block comment, read until end marker.
- while (CanConsume(2)) {
- if (*NextChar() == '*' && *NextChar() == '/') {
+ while (CanConsume(1)) {
+ next_char = *NextChar();
+ if (previous_char == '*' && next_char == '/') {
// EatWhitespaceAndComments will inspect pos_, which will still be on
// the last / of the comment, so advance once more (which may also be
// end of input).
NextChar();
return true;
}
+ previous_char = next_char;
}
// If the comment is unterminated, GetNextToken will report T_END_OF_INPUT.
« no previous file with comments | « no previous file | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698