diff --git a/CHANGELOG.md b/CHANGELOG.md index 014929af3..b47848b9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file. - [#2499] Information about frames which do not have ShowFrame tag - [#2504] WebP image format for export/import (not animated) Limitation: It's not available on Mac x86-64 platform +- [#2519] AS1/2 P-code editation - better handling of "too large" error messages ### Fixed - [#2474] Gotos incorrectly decompiled @@ -3969,6 +3970,7 @@ Major version of SWF to XML export changed to 2. [#2485]: https://www.free-decompiler.com/flash/issues/2485 [#2499]: https://www.free-decompiler.com/flash/issues/2499 [#2504]: https://www.free-decompiler.com/flash/issues/2504 +[#2519]: https://www.free-decompiler.com/flash/issues/2519 [#2474]: https://www.free-decompiler.com/flash/issues/2474 [#2480]: https://www.free-decompiler.com/flash/issues/2480 [#2338]: https://www.free-decompiler.com/flash/issues/2338 @@ -3988,7 +3990,6 @@ Major version of SWF to XML export changed to 2. [#2515]: https://www.free-decompiler.com/flash/issues/2515 [#2516]: https://www.free-decompiler.com/flash/issues/2516 [#2517]: https://www.free-decompiler.com/flash/issues/2517 -[#2519]: https://www.free-decompiler.com/flash/issues/2519 [#2476]: https://www.free-decompiler.com/flash/issues/2476 [#2404]: https://www.free-decompiler.com/flash/issues/2404 [#1418]: https://www.free-decompiler.com/flash/issues/1418 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java index 339292103..748ef5c47 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/pcode/ASMParser.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.parser.pcode; +import com.jpexs.decompiler.flash.ValueTooLargeException; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.flash.action.flashlite.ActionFSCommand2; @@ -386,7 +387,12 @@ public class ASMParser { throw new ActionParseException("Block end without start", lexer.yyline()); } GraphSourceItemContainer a = containers.peek(); - if (!a.parseDivision(0, lexer)) { + if (!a.parseDivision(0, lexer)) { + try { + ((Action) a).getBytes(version); + } catch (ValueTooLargeException vtl) { + throw new ActionParseException("Action container is too large", lexer.yyline()); + } containers.pop(); } } else if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) { @@ -394,6 +400,12 @@ public class ASMParser { Action a = parseAction(instructionName, lexer, emptyList, version, charset); if (a instanceof GraphSourceItemContainer) { containers.push((GraphSourceItemContainer) a); + } else if (a != null) { + try { + ((Action) a).getBytes(version); + } catch (ValueTooLargeException vtl) { + throw new ActionParseException("Action is too large", lexer.yyline()); + } } if (a != null) { list.add(a); @@ -455,6 +467,12 @@ public class ASMParser { GraphSourceItemContainer a = containers.peek(); if (!a.parseDivision(address - ((Action) a).getAddress(), lexer)) { containers.pop(); + + try { + ((Action) a).getBytes(version); + } catch (ValueTooLargeException vtl) { + throw new ActionParseException("Action container is too large", lexer.yyline()); + } } } else if (symb.type == ASMParsedSymbol.TYPE_INSTRUCTION_NAME) { String instructionName = (String) symb.value; @@ -474,6 +492,12 @@ public class ASMParser { } if (a instanceof GraphSourceItemContainer) { containers.push((GraphSourceItemContainer) a); + } else if (a != null) { + try { + ((Action) a).getBytes(version); + } catch (ValueTooLargeException vtl) { + throw new ActionParseException("Action is too large", lexer.yyline()); + } } if (a != null) { list.add(a); @@ -533,7 +557,7 @@ public class ASMParser { if (actionJump.identifier.equals(label.name)) { int offset = (int) (label.address - (actionJump.getAddress() + actionJump.getTotalActionLength())); if (offset < -0x8000 || offset > 0x7fff) { - String message = "Jump offset is too large:" + offset + " addr: ofs" + Helper.formatAddress(link.getAddress()); + String message = "ActionJump offset is too large. offset: " + offset + ", jump action addr: ofs" + Helper.formatAddress(link.getAddress())+", target label: " + label.name; if (throwOnError) { Integer line = lineMap.get(link); if (line == null) { @@ -559,7 +583,7 @@ public class ASMParser { if (actionIf.identifier.equals(label.name)) { int offset = (int) (label.address - (actionIf.getAddress() + actionIf.getTotalActionLength())); if (offset < -0x8000 || offset > 0x7fff) { - String message = "If offset is too large:" + offset + " addr: ofs" + Helper.formatAddress(link.getAddress()); + String message = "ActionIf offset is too large. offset: " + offset + ", jump action addr: ofs" + Helper.formatAddress(link.getAddress())+", target label: " + label.name; if (throwOnError) { Integer line = lineMap.get(link); if (line == null) { diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 550796c11..b35524309 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -1394,9 +1394,10 @@ public class ActionPanel extends JPanel implements SearchListener