From 7f19090c32cbc8da3a1828bb4d43a6df3672c6a3 Mon Sep 17 00:00:00 2001 From: Matteo Esposito <61784966+Esposito-Matteo@users.noreply.github.com> Date: Sun, 8 Aug 2021 22:50:19 +0200 Subject: [PATCH] Fixed Null Pointer exception There was an unsafe assignment @ ex line 1935 where the result of the call to visit method was directly passed to the string buildere without checking for it's possibility to be null. The fix is as easy as it can be, it reports the null value and set it as an empty string, the reson behind it's null value should be looked into it. --- src/main/java/ghaffarian/progex/java/JavaASTBuilder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ghaffarian/progex/java/JavaASTBuilder.java b/src/main/java/ghaffarian/progex/java/JavaASTBuilder.java index 02922cd..f1e5640 100644 --- a/src/main/java/ghaffarian/progex/java/JavaASTBuilder.java +++ b/src/main/java/ghaffarian/progex/java/JavaASTBuilder.java @@ -1392,7 +1392,12 @@ public String visitArrayInitializer(JavaParser.ArrayInitializerContext ctx) { @Override public String visitExpressionList(JavaParser.ExpressionListContext ctx) { // expressionList : expression (',' expression)* - StringBuilder normalized = new StringBuilder(visit(ctx.expression(0))); + String visitStr = visit(ctx.expression(0)); + if(visitStr == null){ + System.err.println("visit is "+ visitStr); + visitStr = ""; + } + StringBuilder normalized = new StringBuilder(visitStr); for (int i = 1; i < ctx.expression().size(); ++i) normalized.append(", ").append(visit(ctx.expression(i))); return normalized.toString();