From ff4484d06626e779a50fa165e880e9e2ed1c28cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 24 Aug 2014 07:09:50 +0200 Subject: [PATCH] fileattributes exception fix - reading again workaround --- .../jpexs/decompiler/flash/SWFInputStream.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/SWFInputStream.java b/src/com/jpexs/decompiler/flash/SWFInputStream.java index 87df31371..04e10b30d 100644 --- a/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -1010,6 +1010,9 @@ public class SWFInputStream implements AutoCloseable { executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get()); futureResults = new ArrayList<>(); } + int tagCnt = 0; + int faPos = 0; + FileAttributesTag fileAttributes = null; List tags = new ArrayList<>(); Tag tag; boolean isAS3 = false; @@ -1021,6 +1024,7 @@ public class SWFInputStream implements AutoCloseable { } catch (EOFException | EndOfStreamException ex) { tag = null; } + tagCnt++; DumpInfo di = dumpInfo; if (di != null && tag != null) { di.name = tag.getName(); @@ -1044,11 +1048,11 @@ public class SWFInputStream implements AutoCloseable { } else { switch (tag.getId()) { case FileAttributesTag.ID: //FileAttributes - Tag ft = tag; - if (ft instanceof TagStub) { - ft = resolveTag((TagStub) tag, level, parallel, skipUnusualTags); + faPos = tagCnt-1; //should be 0, as it is first tag, but anyway + if (tag instanceof TagStub) { + tag = resolveTag((TagStub) tag, level, parallel, skipUnusualTags); } - FileAttributesTag fileAttributes = (FileAttributesTag) ft; + fileAttributes = (FileAttributesTag) tag; if (fileAttributes.actionScript3) { isAS3 = true; } @@ -1112,6 +1116,10 @@ public class SWFInputStream implements AutoCloseable { executor.shutdown(); } + //Workaround to not reading fileattributes twice. TODO:Handle this better + if(parallel && fileAttributes!=null){ + tags.add(faPos,fileAttributes); + } return tags; }