From 05c9f6c3a2458ecdedbce1468b7a8cd2e0ca2b6f Mon Sep 17 00:00:00 2001 From: zaaarf Date: Thu, 13 Apr 2023 18:36:05 +0200 Subject: fix: nullptr in PatternMatcher --- src/main/java/ftbsc/lll/tools/PatternMatcher.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/ftbsc/lll/tools/PatternMatcher.java b/src/main/java/ftbsc/lll/tools/PatternMatcher.java index c5a53a2..ff4423a 100644 --- a/src/main/java/ftbsc/lll/tools/PatternMatcher.java +++ b/src/main/java/ftbsc/lll/tools/PatternMatcher.java @@ -83,11 +83,10 @@ public class PatternMatcher { if(predicates.size() == 0) return new InsnSequence(cur); //match whatever first = cur; last = cur; - for(int match = 0; match < predicates.size(); last = reverse ? last.getPrevious() : last.getNext()) { + for(int match = 0; last != null && match < predicates.size(); last = reverse ? last.getPrevious() : last.getNext()) { if(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue; if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue; if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue; - if(last == null) break; if(!predicates.get(match).test(last)) break; if(match == predicates.size() - 1) { if(reverse) return new InsnSequence(last, first); //we are matching backwards -- cgit v1.2.3-56-ga3b1