From 2bd1208f868b2f22861c9beaf1de7dbd94dc53da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 20 Dec 2022 10:38:49 +0100 Subject: [PATCH] Fixed #1904 NullPointerException on decompiler pool Fixed #1904 AS1/2 Simplify expressions breaks registers, functions --- CHANGELOG.md | 2 ++ .../jpexs/decompiler/flash/DecompilerPool.java | 16 +++++++++------- .../action/model/DirectValueActionItem.java | 2 +- .../flash/action/model/FunctionActionItem.java | 4 +++- .../action/model/StoreRegisterActionItem.java | 3 +++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ac3cbc84..60f3541d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. - [#1904] NullPointerException when renaming invalid identifiers in AS1/2 files caused by missing charset - [#1904] NullPointerException when fast switching items - [#1904] NullPointerException on ErrorLog frame +- [#1904] NullPointerException on decompiler pool +- [#1904] AS1/2 Simplify expressions breaks registers, functions ### Changed - Warning before switching deobfuscation is now optional diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DecompilerPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DecompilerPool.java index 7a53a5167..f0f46b387 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DecompilerPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/DecompilerPool.java @@ -109,7 +109,7 @@ public class DecompilerPool { HighlightedText result = new HighlightedText(writer); Openable openable = pack.getOpenable(); - SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC)openable).getSwf(); + SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf(); if (swf != null) { swf.as3Cache.put(pack, result); } @@ -210,13 +210,15 @@ public class DecompilerPool { if (!executor.awaitTermination(100, TimeUnit.SECONDS)) { } } - - public void destroySwf(SWF swf){ + + public void destroySwf(SWF swf) { List> futures = openableToFutures.get(swf); - if(futures!=null){ - for(Future future:futures){ - future.cancel(true); - } + if (futures != null) { + for (Future future : futures) { + if (future != null) { + future.cancel(true); + } + } } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index 9ae337089..60b0a8ffb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -206,7 +206,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { } dependencies.add(computedRegValue); } - return (value instanceof Double) || (value instanceof Float) || (value instanceof Boolean) || (value instanceof Long) || (value == Null.INSTANCE) || (computedRegValue != null && computedRegValue.isCompileTime(dependencies)) || (value instanceof String) || (value instanceof ConstantIndex); + return (value instanceof Double) || (value instanceof Float) || (value instanceof Boolean) || (value instanceof Long) || (value == Null.INSTANCE) || (value instanceof String) || (value instanceof ConstantIndex); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java index f734b1995..61ce17004 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java @@ -225,6 +225,8 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista return false; } + /* + NOT COMPILE TIME! This causes problems in simplifyExpressions, etc. @Override public boolean isCompileTime(Set dependencies) { for (GraphTargetItem a : actions) { @@ -237,7 +239,7 @@ public class FunctionActionItem extends ActionItem implements BranchStackResista } } return true; - } + }*/ @Override public Object getResult() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java index 25b79be51..d4aab0f93 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java @@ -136,6 +136,8 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction return true; } + /* + NOT COMPILE TIME! This causes problems in simplifyExpressions, etc. @Override public boolean isCompileTime(Set dependencies) { if (dependencies.contains(value)) { @@ -144,6 +146,7 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction dependencies.add(value); return value.isCompileTime(dependencies); } + */ @Override public Object getResult() {