From 4dd2818f0ee09dba90e206cc67eb16082a222fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 4 Mar 2023 09:52:54 +0100 Subject: [PATCH] Fixed #1986 AS2 Class detection - NullPointerException on certain classes --- CHANGELOG.md | 2 ++ .../action/ActionScript2ClassDetector.java | 30 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ee6e9398..04180c113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. - AS3 Metadata single value (null item key) - [#1981] AS3 star import collisions - [#1982] Slow calculation of large shape outlines - now use only rectangles for large shapes +- [#1986] AS2 Class detection - NullPointerException on certain classes ### Changed - AS1/2/3 P-code - format Number values with EcmaScript toString function @@ -2985,6 +2986,7 @@ All notable changes to this project will be documented in this file. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#1981]: https://www.free-decompiler.com/flash/issues/1981 [#1982]: https://www.free-decompiler.com/flash/issues/1982 +[#1986]: https://www.free-decompiler.com/flash/issues/1986 [#1970]: https://www.free-decompiler.com/flash/issues/1970 [#1972]: https://www.free-decompiler.com/flash/issues/1972 [#1973]: https://www.free-decompiler.com/flash/issues/1973 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScript2ClassDetector.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScript2ClassDetector.java index 17f826bf5..9463d7fe9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScript2ClassDetector.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionScript2ClassDetector.java @@ -279,7 +279,7 @@ public class ActionScript2ClassDetector { } private boolean checkClassContent(List parts, HashMap variables, int partsPos, int commandsStartPos, int commandsEndPos, List commands, List classNamePath, String scriptPath) { - + try { GraphTargetItem extendsOp = null; @@ -299,7 +299,7 @@ public class ActionScript2ClassDetector { StoreRegisterActionItem sr = (StoreRegisterActionItem) item; definedRegisters.add(sr.register.number); } - } + } if (parts.size() > partsPos) { item = parts.get(partsPos); @@ -341,16 +341,18 @@ public class ActionScript2ClassDetector { List protoPath = new ArrayList<>(classNamePath); protoPath.add("prototype"); List smPath = getSetMembersPath(sm); - if (smPath.get(0).equals("_global")) { - smPath.remove(0); - } - if (smPath.equals(protoPath)) { - if (sm.value instanceof StoreRegisterActionItem) { - partsPos++; - if (parts.size() > partsPos) { - item = parts.get(partsPos); - } else { - item = null; + if (smPath != null) { //null = can start with TempRegister for example + if (smPath.get(0).equals("_global")) { + smPath.remove(0); + } + if (smPath.equals(protoPath)) { + if (sm.value instanceof StoreRegisterActionItem) { + partsPos++; + if (parts.size() > partsPos) { + item = parts.get(partsPos); + } else { + item = null; + } } } } @@ -695,7 +697,7 @@ public class ActionScript2ClassDetector { } else if (item instanceof DirectValueActionItem) { //ignore such values //TODO: maybe somehow display in the class ? - } else if (item instanceof ScriptEndItem){ + } else if (item instanceof ScriptEndItem) { //ignore } else { throw new AssertException("unknown item - " + item.getClass().getSimpleName()); @@ -819,7 +821,7 @@ public class ActionScript2ClassDetector { return true; } else { break check_variant1; - } + } } else if (this.checkClassContent(ifItem.onTrue, variables, 0, pos, checkPos, commands, classPath, scriptPath)) { return true; } else {