diff --git a/javascript/extractor/src/com/semmle/js/parser/JSONParser.java b/javascript/extractor/src/com/semmle/js/parser/JSONParser.java index fb2c06e82bc..26af68b0cd3 100644 --- a/javascript/extractor/src/com/semmle/js/parser/JSONParser.java +++ b/javascript/extractor/src/com/semmle/js/parser/JSONParser.java @@ -79,7 +79,7 @@ public class JSONParser { } private char peek() { - return offset < length ? src.charAt(offset) : (char) -1; + return offset < length ? src.charAt(offset) : Character.MAX_VALUE; } private JSONValue readValue() throws ParseError { @@ -356,7 +356,7 @@ public class JSONParser { char c; next(); next(); - while ((c = peek()) != '\r' && c != '\n') next(); + while ((c = peek()) != '\r' && c != '\n' && c != Character.MAX_VALUE) next(); } /** Skips the block comment starting at the current position. */ @@ -367,6 +367,7 @@ public class JSONParser { next(); do { c = peek(); + if (c == Character.MAX_VALUE) raise("Unterminated comment"); next(); if (c == '*' && peek() == '/') { next();