From b13dee2567853b059ff0c1125b78f860667f5bd7 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 26 Jun 2014 14:09:36 +0200 Subject: [PATCH] null check added --- .../modules/decompiler/ExitHelper.java | 10 +++--- .../modules/decompiler/ExprProcessor.java | 34 ++++--------------- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/de/fernflower/modules/decompiler/ExitHelper.java b/src/de/fernflower/modules/decompiler/ExitHelper.java index 7e4f10b..8cf9235 100644 --- a/src/de/fernflower/modules/decompiler/ExitHelper.java +++ b/src/de/fernflower/modules/decompiler/ExitHelper.java @@ -212,7 +212,7 @@ public class ExitHelper { && edge.explicit && (edge.labeled || isOnlyEdge(edge))) { List data = dest.getExprents(); - if(data.size() == 1) { + if(data != null && data.size() == 1) { if(data.get(0).type == Exprent.EXPRENT_EXIT) { return dest; } @@ -252,8 +252,8 @@ public class ExitHelper { for(StatEdge edge: root.getDummyExit().getAllPredecessorEdges()) { if(!edge.explicit) { Statement source = edge.getSource(); - if(source.getExprents() != null && !source.getExprents().isEmpty()) { - List lstExpr = source.getExprents(); + List lstExpr = source.getExprents(); + if(lstExpr != null && !lstExpr.isEmpty()) { Exprent expr = lstExpr.get(lstExpr.size() - 1); if(expr.type == Exprent.EXPRENT_EXIT) { ExitExprent ex = (ExitExprent)expr; @@ -289,8 +289,8 @@ public class ExitHelper { } Statement source = edge.getSource(); - if(source.getExprents() != null && !source.getExprents().isEmpty()) { - List lstExpr = source.getExprents(); + List lstExpr = source.getExprents(); + if(lstExpr != null && !lstExpr.isEmpty()) { Exprent expr = lstExpr.get(lstExpr.size() - 1); if(expr.type == Exprent.EXPRENT_EXIT) { ExitExprent ex = (ExitExprent)expr; diff --git a/src/de/fernflower/modules/decompiler/ExprProcessor.java b/src/de/fernflower/modules/decompiler/ExprProcessor.java index c640bc1..64962c5 100644 --- a/src/de/fernflower/modules/decompiler/ExprProcessor.java +++ b/src/de/fernflower/modules/decompiler/ExprProcessor.java @@ -14,42 +14,19 @@ package de.fernflower.modules.decompiler; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import de.fernflower.code.CodeConstants; import de.fernflower.code.Instruction; import de.fernflower.code.InstructionSequence; import de.fernflower.code.cfg.BasicBlock; import de.fernflower.main.DecompilerContext; -import de.fernflower.main.extern.IFernflowerPreferences; -import de.fernflower.modules.decompiler.exps.ArrayExprent; -import de.fernflower.modules.decompiler.exps.AssignmentExprent; -import de.fernflower.modules.decompiler.exps.ConstExprent; -import de.fernflower.modules.decompiler.exps.ExitExprent; -import de.fernflower.modules.decompiler.exps.Exprent; -import de.fernflower.modules.decompiler.exps.FieldExprent; -import de.fernflower.modules.decompiler.exps.FunctionExprent; -import de.fernflower.modules.decompiler.exps.IfExprent; -import de.fernflower.modules.decompiler.exps.InvocationExprent; -import de.fernflower.modules.decompiler.exps.MonitorExprent; -import de.fernflower.modules.decompiler.exps.NewExprent; -import de.fernflower.modules.decompiler.exps.SwitchExprent; -import de.fernflower.modules.decompiler.exps.VarExprent; +import de.fernflower.modules.decompiler.exps.*; import de.fernflower.modules.decompiler.sforms.DirectGraph; import de.fernflower.modules.decompiler.sforms.DirectNode; import de.fernflower.modules.decompiler.sforms.FlattenStatementsHelper; import de.fernflower.modules.decompiler.sforms.FlattenStatementsHelper.FinallyPathWrapper; -import de.fernflower.modules.decompiler.stats.BasicBlockStatement; -import de.fernflower.modules.decompiler.stats.CatchAllStatement; -import de.fernflower.modules.decompiler.stats.CatchStatement; -import de.fernflower.modules.decompiler.stats.RootStatement; -import de.fernflower.modules.decompiler.stats.Statement; +import de.fernflower.modules.decompiler.stats.*; import de.fernflower.modules.decompiler.vars.VarProcessor; import de.fernflower.struct.StructClass; import de.fernflower.struct.consts.ConstantPool; @@ -756,8 +733,11 @@ public class ExprProcessor implements CodeConstants { } public static String listToJava(List lst, int indent) { - String indstr = InterpreterUtil.getIndentString(indent); + if (lst == null || lst.isEmpty()) { + return ""; + } + String indstr = InterpreterUtil.getIndentString(indent); String new_line_separator = DecompilerContext.getNewLineSeparator(); StringBuffer buf = new StringBuffer();