Skip to content

Commit

Permalink
Fix NPE (bazelbuild#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
poseidon-mysugr authored Feb 20, 2020
1 parent 23c2ca7 commit 3b95f61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public void nextIsType() {

@Test
public void firstIsALoad0() {
// should set cursor to null when no opcodes are present
matcher.firstIsALoad0(m);
assertNull(matcher.cursor);

// should set cursor to null when opcode mismatch
m.visitInsn(Opcodes.NOP);
matcher.firstIsALoad0(m);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class AbstractMatcher {
final void firstIsALoad0(final MethodNode methodNode) {
cursor = methodNode.instructions.getFirst();
skipNonOpcodes();
if (cursor.getOpcode() == Opcodes.ALOAD
if (cursor != null && cursor.getOpcode() == Opcodes.ALOAD
&& ((VarInsnNode) cursor).var == 0) {
return;
}
Expand Down

0 comments on commit 3b95f61

Please sign in to comment.