Skip to content

Commit

Permalink
Merge pull request #275 from Fraunhofer-AISEC/fix-npe-in-expression-h…
Browse files Browse the repository at this point in the history
…andler

Fixed NPE in ExpressionHandler
  • Loading branch information
konradweiss authored Nov 28, 2020
2 parents 8b91b4e + 7a15078 commit 0192552
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,15 @@ private Expression handleSimpleTypeConstructorExpression(
private Expression handleFieldReference(CPPASTFieldReference ctx) {
Expression base = this.handle(ctx.getFieldOwner());
// Replace Literal this with a reference pointing to this
if (base instanceof Literal && ((Literal) base).getValue().equals("this")) {
if (base instanceof Literal && ((Literal<?>) base).getValue().equals("this")) {
PhysicalLocation location = base.getLocation();

var record = lang.getScopeManager().getCurrentRecord();

base =
NodeBuilder.newDeclaredReferenceExpression(
"this",
lang.getScopeManager().getCurrentRecord().getThis().getType(),
record != null ? record.getThis().getType() : UnknownType.getUnknownType(),
base.getCode());
base.setLocation(location);
}
Expand Down

0 comments on commit 0192552

Please sign in to comment.