Skip to content

Commit

Permalink
fix: handle NPE for methods with removed instructions (#342) (PR #583)
Browse files Browse the repository at this point in the history
  • Loading branch information
asashour authored and skylot committed Apr 12, 2019
1 parent eb77aa5 commit 395cae4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ private static void checkStaticFieldsInit(ClassNode cls) {
MethodNode clinit = cls.getClassInitMth();
if (clinit == null
|| !clinit.getAccessFlags().isStatic()
|| clinit.isNoCode()) {
|| clinit.isNoCode()
|| clinit.getBasicBlocks() == null) {
return;
}

Expand Down Expand Up @@ -235,7 +236,7 @@ private static List<MethodNode> getConstructorsList(ClassNode cls) {
}

private static List<InsnNode> getFieldAssigns(MethodNode mth, FieldNode field, InsnType putInsn) {
if (mth.isNoCode()) {
if (mth.isNoCode() || mth.getBasicBlocks() == null) {
return Collections.emptyList();
}
List<InsnNode> assignInsns = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private static void processEnumSwitch(MethodNode mth, SwitchNode insn) {

private static void initClsEnumMap(ClassNode enumCls) {
MethodNode clsInitMth = enumCls.getClassInitMth();
if (clsInitMth == null || clsInitMth.isNoCode()) {
if (clsInitMth == null || clsInitMth.isNoCode() || clsInitMth.getBasicBlocks() == null) {
return;
}
EnumMapAttr mapAttr = new EnumMapAttr();
Expand Down

0 comments on commit 395cae4

Please sign in to comment.