fix: nullptr in PatternMatcher

This commit is contained in:
zaaarf 2023-04-13 18:36:05 +02:00
parent dd09c4f8e1
commit 05c9f6c3a2
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C

View file

@ -83,11 +83,10 @@ public class PatternMatcher {
if(predicates.size() == 0) return new InsnSequence(cur); //match whatever if(predicates.size() == 0) return new InsnSequence(cur); //match whatever
first = cur; first = cur;
last = 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(ignoreLabels && cur.getType() == AbstractInsnNode.LABEL) continue;
if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue; if(ignoreFrames && cur.getType() == AbstractInsnNode.FRAME) continue;
if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue; if(ignoreLineNumbers && cur.getType() == AbstractInsnNode.LINE) continue;
if(last == null) break;
if(!predicates.get(match).test(last)) break; if(!predicates.get(match).test(last)) break;
if(match == predicates.size() - 1) { if(match == predicates.size() - 1) {
if(reverse) return new InsnSequence(last, first); //we are matching backwards if(reverse) return new InsnSequence(last, first); //we are matching backwards