Skip to content

Commit 737c747

Browse files
committed
early exit if string becomes too big
1 parent 1ba6f44 commit 737c747

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,17 @@ private Pair<String, OffsetTranslation> getStringConcatResult(Expression exp) {
606606
if (be.getOperator().equals("+")) {
607607
Pair<String, OffsetTranslation> left = getStringConcatResult(be.getLeft());
608608
Pair<String, OffsetTranslation> right = getStringConcatResult(be.getRight());
609-
if (left != null && right != null) {
610-
String str = left.fst() + right.fst();
611-
612-
int delta = be.getRight().getLoc().getStart().getOffset() - be.getLeft().getLoc().getStart().getOffset();
613-
int offset = left.fst().length();
614-
return Pair.make(str, left.snd().append(right.snd(), offset, delta));
609+
if (left == null || right == null) {
610+
return null;
611+
}
612+
String str = left.fst() + right.fst();
613+
if (str.length() > 1000) {
614+
return null;
615615
}
616+
617+
int delta = be.getRight().getLoc().getStart().getOffset() - be.getLeft().getLoc().getStart().getOffset();
618+
int offset = left.fst().length();
619+
return Pair.make(str, left.snd().append(right.snd(), offset, delta));
616620
}
617621
} else if (exp instanceof Literal) {
618622
Literal lit = (Literal) exp;

0 commit comments

Comments
 (0)