mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-15 18:21:53 +00:00
AS2 parser: add string to constant pool, if there is enough space
This commit is contained in:
@@ -1810,9 +1810,17 @@ public class ActionScript2Parser {
|
||||
private DirectValueActionItem pushConst(String s) throws IOException, ActionParseException {
|
||||
int index = constantPool.indexOf(s);
|
||||
if (index == -1) {
|
||||
constantPool.add(s);
|
||||
index = constantPool.indexOf(s);
|
||||
if (ActionConstantPool.calculateSize(constantPool) + ActionConstantPool.calculateSize(s) <= 0xffff) {
|
||||
// constant pool is not full
|
||||
constantPool.add(s);
|
||||
index = constantPool.indexOf(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
return new DirectValueActionItem(null, 0, s, constantPool);
|
||||
}
|
||||
|
||||
return new DirectValueActionItem(null, 0, new ConstantIndex(index), constantPool);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,10 @@ public class ActionConstantPool extends Action {
|
||||
return calculateSize(constantPool);
|
||||
}
|
||||
|
||||
public static int calculateSize(String str) {
|
||||
return Utf8Helper.getBytesLength(str) + 1;
|
||||
}
|
||||
|
||||
public static int calculateSize(List<String> strings) {
|
||||
int res = 2;
|
||||
for (String s : strings) {
|
||||
|
||||
Reference in New Issue
Block a user