From 0111f1ef56e33b682101b3072b831bebcdd0d998 Mon Sep 17 00:00:00 2001 From: gegy1000 Date: Sat, 16 Feb 2019 18:02:14 +0200 Subject: Fix NPE dropping mappings --- .../cuchaz/enigma/translation/mapping/tree/HashEntryTree.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/cuchaz/enigma') diff --git a/src/main/java/cuchaz/enigma/translation/mapping/tree/HashEntryTree.java b/src/main/java/cuchaz/enigma/translation/mapping/tree/HashEntryTree.java index fa9ed13..c5fc473 100644 --- a/src/main/java/cuchaz/enigma/translation/mapping/tree/HashEntryTree.java +++ b/src/main/java/cuchaz/enigma/translation/mapping/tree/HashEntryTree.java @@ -115,16 +115,19 @@ public class HashEntryTree implements EntryTree { Entry rootEntry = ancestry.get(0); HashTreeNode node = make ? root.computeIfAbsent(rootEntry, HashTreeNode::new) : root.get(rootEntry); + if (node == null) { + return Collections.emptyList(); + } + path.add(node); for (int i = 1; i < ancestry.size(); i++) { + Entry ancestor = ancestry.get(i); + node = make ? node.computeChild(ancestor) : node.getChild(ancestor); if (node == null) { return Collections.emptyList(); } - Entry ancestor = ancestry.get(i); - node = make ? node.computeChild(ancestor) : node.getChild(ancestor); - path.add(node); } -- cgit v1.2.3