Skip to content

Commit ff62c65

Browse files
committed
Javascript: avoid null pointer exception on boolean values
1 parent 6ef314e commit ff62c65

17 files changed

+22
-22
lines changed

javascript/extractor/src/com/semmle/jcorn/Parser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,7 @@ protected BlockStatement parseBlock(boolean allowStrict) {
31153115
}
31163116
first = false;
31173117
}
3118-
if (oldStrict.equals(Boolean.FALSE)) this.setStrict(false);
3118+
if (Boolean.FALSE.equals(oldStrict)) this.setStrict(false);
31193119
return this.finishNode(new BlockStatement(new SourceLocation(startLoc), body));
31203120
}
31213121

javascript/extractor/src/com/semmle/js/ast/AFunctionExpression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public AFunctionExpression(
3535
id,
3636
params,
3737
body,
38-
generator.equals(Boolean.TRUE),
39-
async.equals(Boolean.TRUE),
38+
Boolean.TRUE.equals(generator),
39+
Boolean.TRUE.equals(async),
4040
typeParameters,
4141
parameterTypes,
4242
parameterDecorators,

javascript/extractor/src/com/semmle/js/ast/ComprehensionBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public ComprehensionBlock(SourceLocation loc, IPattern left, Expression right, B
1010
super("ComprehensionBlock", loc);
1111
this.left = left;
1212
this.right = right;
13-
this.of = !of.equals(Boolean.FALSE);
13+
this.of = !Boolean.FALSE.equals(of);
1414
}
1515

1616
@Override

javascript/extractor/src/com/semmle/js/ast/ComprehensionExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public ComprehensionExpression(
1919
this.body = body;
2020
this.blocks = blocks;
2121
this.filter = filter;
22-
this.generator = generator.equals(Boolean.TRUE);
22+
this.generator = Boolean.TRUE.equals(generator);
2323
}
2424

2525
@Override

javascript/extractor/src/com/semmle/js/ast/ForInStatement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ForInStatement extends EnhancedForStatement {
1616
public ForInStatement(
1717
SourceLocation loc, Node left, Expression right, Statement body, Boolean each) {
1818
super("ForInStatement", loc, left, right, body);
19-
this.each = each.equals(Boolean.TRUE);
19+
this.each = Boolean.TRUE.equals(each);
2020
}
2121

2222
public boolean isEach() {

javascript/extractor/src/com/semmle/js/ast/InvokeExpression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public InvokeExpression(
2727
this.callee = callee;
2828
this.typeArguments = typeArguments;
2929
this.arguments = arguments;
30-
this.optional = optional.equals(Boolean.TRUE);
31-
this.onOptionalChain = onOptionalChain.equals(Boolean.TRUE);
30+
this.optional = Boolean.TRUE.equals(optional);
31+
this.onOptionalChain = Boolean.TRUE.equals(onOptionalChain);
3232
}
3333

3434
/** The callee expression of this invocation. */

javascript/extractor/src/com/semmle/js/ast/Literal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public boolean isFalsy() {
7676
if (isRegExp()) return false;
7777
return value == null
7878
|| value instanceof Number && ((Number) value).intValue() == 0
79-
|| value.equals(Boolean.FALSE)
79+
|| Boolean.FALSE.equals(value)
8080
|| value instanceof String && ((String) value).isEmpty();
8181
}
8282

javascript/extractor/src/com/semmle/js/ast/MemberExpression.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public MemberExpression(
2222
super("MemberExpression", loc);
2323
this.object = object;
2424
this.property = property;
25-
this.computed = computed.equals(Boolean.TRUE);
26-
this.optional = optional.equals(Boolean.TRUE);
27-
this.onOptionalChain = onOptionalChain.equals(Boolean.TRUE);
25+
this.computed = Boolean.TRUE.equals(computed);
26+
this.optional = Boolean.TRUE.equals(optional);
27+
this.onOptionalChain = Boolean.TRUE.equals(onOptionalChain);
2828
}
2929

3030
@Override

javascript/extractor/src/com/semmle/js/ast/Property.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public Property(
5959
}
6060
this.rawValue = rawValue;
6161
this.kind = Kind.valueOf(StringUtil.uc(kind));
62-
this.computed = computed.equals(Boolean.TRUE);
63-
this.method = method.equals(Boolean.TRUE);
62+
this.computed = Boolean.TRUE.equals(computed);
63+
this.method = Boolean.TRUE.equals(method);
6464
this.decorators = new ArrayList<Decorator>();
6565
}
6666

javascript/extractor/src/com/semmle/js/ast/TemplateElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public TemplateElement(SourceLocation loc, Object cooked, String raw, Boolean ta
1010
super("TemplateElement", loc);
1111
this.cooked = cooked;
1212
this.raw = raw;
13-
this.tail = tail.equals(Boolean.TRUE);
13+
this.tail = Boolean.TRUE.equals(tail);
1414
}
1515

1616
@Override

0 commit comments

Comments
 (0)