Fixed: #2405 Incorrect saving tags after Cloning / Copy-pasting

This commit is contained in:
Jindra Petřík
2025-06-06 05:43:21 +02:00
parent debcbbd7c5
commit 39cd80ffc2
2 changed files with 9 additions and 1 deletions

View File

@@ -60,6 +60,7 @@ All notable changes to this project will be documented in this file.
- AS3 difference between namespace keyword and const of type Namespace
- [#2462] AS3 debugger - incorrect line info injected
- [#2464] SVG export - minimum stroke width of 1 px
- [#2405] Incorrect saving tags after Cloning / Copy-pasting
## [23.0.1] - 2025-05-16
### Fixed
@@ -3854,6 +3855,7 @@ Major version of SWF to XML export changed to 2.
[#2461]: https://www.free-decompiler.com/flash/issues/2461
[#2462]: https://www.free-decompiler.com/flash/issues/2462
[#2464]: https://www.free-decompiler.com/flash/issues/2464
[#2405]: https://www.free-decompiler.com/flash/issues/2405
[#2427]: https://www.free-decompiler.com/flash/issues/2427
[#1826]: https://www.free-decompiler.com/flash/issues/1826
[#2448]: https://www.free-decompiler.com/flash/issues/2448

View File

@@ -581,9 +581,15 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
* @throws IOException On I/O error
*/
public Tag cloneTag() throws InterruptedException, IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] data = getData();
byte[] headerData = getHeader(data.length);
baos.write(headerData);
baos.write(data);
byte[] dataWithHeader = baos.toByteArray();
SWFInputStream tagDataStream = new SWFInputStream(swf, data, 0, data.length);
TagStub copy = new TagStub(swf, getId(), "Unresolved", new ByteArrayRange(data), tagDataStream);
TagStub copy = new TagStub(swf, getId(), "Unresolved", new ByteArrayRange(dataWithHeader), tagDataStream);
copy.forceWriteAsLong = forceWriteAsLong;
return SWFInputStream.resolveTag(copy, 0, false, true, false, false);
}