From 7a4bec0d98b0efeb497bf3cc350a4672cab58f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 31 Dec 2022 15:03:03 +0100 Subject: [PATCH] Fixed #1772 AS1/2 decompilation - StackOverflow during getVariables function --- CHANGELOG.md | 2 ++ .../src/com/jpexs/decompiler/flash/action/Action.java | 2 +- libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dcb1fced..bccd1e2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. - Uncompressed FLA (XFL) export creates a directory - [#1827] Video replacing VP6 reading - [#1926] Constructors namespace taken from class - should be always public +- [#1772] AS1/2 decompilation - StackOverflow during getVariables function ### Changed - [#1913] SVG export/import of shapes - shape exact position (bounds) is retained @@ -2832,6 +2833,7 @@ All notable changes to this project will be documented in this file. [#1923]: https://www.free-decompiler.com/flash/issues/1923 [#1827]: https://www.free-decompiler.com/flash/issues/1827 [#1926]: https://www.free-decompiler.com/flash/issues/1926 +[#1772]: https://www.free-decompiler.com/flash/issues/1772 [#1922]: https://www.free-decompiler.com/flash/issues/1922 [#1921]: https://www.free-decompiler.com/flash/issues/1921 [#1917]: https://www.free-decompiler.com/flash/issues/1917 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 51a5529ac..db062f56e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -999,7 +999,7 @@ public abstract class Action implements GraphSourceItem { } private static HashMap prepareVariables(GraphSourceItemContainer cnt, HashMap variables) { - HashMap variables2 = Helper.deepCopy(variables); + HashMap variables2 = new LinkedHashMap<>(variables); if (cnt instanceof ActionDefineFunction || cnt instanceof ActionDefineFunction2) { for (int r = 0; r < 256; r++) { if (variables2.containsKey("__register" + r)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index eb48234e2..032b5eb5e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -660,7 +660,10 @@ public class Helper { } catch (IOException | ClassNotFoundException ex) { Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, "Copy error", ex); return null; + } catch (StackOverflowError se) { + throw new StackOverflowError("Stack overflow in deepcopy"); } + } public static List toList(Object... rest) {