From 42c343e8205e3bed1b654f0141cdb28e41fbe80f Mon Sep 17 00:00:00 2001 From: Cornelius Riemenschneider Date: Tue, 24 Oct 2023 16:03:35 +0200 Subject: [PATCH] Address review --- .../extractor/src/com/semmle/js/parser/JSONParser.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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();