From a6097b87cfa16b1f07ca6108f485e4a77ffc7373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 6 Oct 2025 18:13:15 +0200 Subject: [PATCH] Fixed: #2540 AS3 getlocal after inclocal with different registers incorrectly merged --- CHANGELOG.md | 2 ++ .../localregs/GetLocalTypeIns.java | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf6cd991..eb4baffd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - [#2536] AS3 switches detection not handling loops - [#2536] AS3 regexp highlighting / compilation - [#2537] AS1/2/3 direct editation - partial object literal causing lag +- [#2540] AS3 getlocal after inclocal with different registers incorrectly merged ## [24.1.0] - 2025-09-28 ### Added @@ -4020,6 +4021,7 @@ Major version of SWF to XML export changed to 2. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#2536]: https://www.free-decompiler.com/flash/issues/2536 [#2537]: https://www.free-decompiler.com/flash/issues/2537 +[#2540]: https://www.free-decompiler.com/flash/issues/2540 [#2477]: https://www.free-decompiler.com/flash/issues/2477 [#2478]: https://www.free-decompiler.com/flash/issues/2478 [#2485]: https://www.free-decompiler.com/flash/issues/2485 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 9137cbea2..a64f124c1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -145,17 +145,23 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { //TestIncDec7 AIR if (!output.isEmpty()) { GraphTargetItem lastOutput = output.get(output.size() - 1); - if (lastOutput instanceof IncLocalAVM2Item) { - output.remove(output.size() - 1); - stack.moveToStack(output); - stack.push(new PreIncrementAVM2Item(lastOutput.getSrc(), lastOutput.getLineStartItem(), result)); - return; + if (lastOutput instanceof IncLocalAVM2Item) { + IncLocalAVM2Item inc = (IncLocalAVM2Item) lastOutput; + if (inc.regIndex == regId) { + output.remove(output.size() - 1); + stack.moveToStack(output); + stack.push(new PreIncrementAVM2Item(lastOutput.getSrc(), lastOutput.getLineStartItem(), result)); + return; + } } - if (output.get(output.size() - 1) instanceof DecLocalAVM2Item) { - output.remove(output.size() - 1); - stack.moveToStack(output); - stack.push(new PreDecrementAVM2Item(lastOutput.getSrc(), lastOutput.getLineStartItem(), result)); - return; + if (lastOutput instanceof DecLocalAVM2Item) { + DecLocalAVM2Item dec = (DecLocalAVM2Item) lastOutput; + if (dec.regIndex == regId) { + output.remove(output.size() - 1); + stack.moveToStack(output); + stack.push(new PreDecrementAVM2Item(lastOutput.getSrc(), lastOutput.getLineStartItem(), result)); + return; + } } }