From 35cfe219a4494b7588334dd57b259e2e4a0c4982 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sat, 18 Jul 2015 08:23:09 +0200 Subject: [PATCH] error message when constant pool is too big --- .../flash/action/swf5/ActionConstantPool.java | 6 +++++- .../decompiler/flash/gui/action/ActionPanel.java | 14 +++++++++++++- .../flash/gui/locales/MainFrame.properties | 2 ++ .../flash/gui/locales/MainFrame_hu.properties | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index fd3f3ed0e..fdfbf6afd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -77,8 +77,12 @@ public class ActionConstantPool extends Action { */ @Override protected int getContentBytesLength() { + return calculateSize(constantPool); + } + + public static int calculateSize(List strings) { int res = 2; - for (String s : constantPool) { + for (String s : strings) { res += Utf8Helper.getBytesLength(s) + 1; } diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 5f25d66ff..511e1e50f 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.action.parser.script.ParsedSymbol; import com.jpexs.decompiler.flash.action.parser.script.SymbolType; import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; +import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.AppStrings; @@ -786,7 +787,16 @@ public class ActionPanel extends JPanel implements SearchListener> constantPools = Helper.getConstantPoolsFromText(text); + for (int i = 0; i < constantPools.size(); i++) { + List constantPool = constantPools.get(i); + int size = ActionConstantPool.calculateSize(constantPool); + if (size > 0xffff) { + View.showMessageDialog(this, AppStrings.translate("error.constantPoolTooBig").replace("%index%", Integer.toString(i)).replace("%size%", Integer.toString(size)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + } + } + + src.setConstantPools(constantPools); } else { src.setActions(ASMParser.parse(0, true, text, src.getSwf().version, false)); } @@ -806,6 +816,8 @@ public class ActionPanel extends JPanel implements SearchListener