diff options
author | shifujun <shifujun@foxmail.com> | 2023-12-11 17:52:52 +0800 |
---|---|---|
committer | shifujun <shifujun@foxmail.com> | 2023-12-11 17:53:08 +0800 |
commit | 2cdc0275b7c7d66a942708e22c07fdbd0246203a (patch) | |
tree | c7e0b6e7dbaf5e37794fd5f86d0c7bc51ac003a3 | |
parent | fbd20b1e112b3e74f6d970a8ced839e8ee0bab87 (diff) | |
download | javassist-2cdc0275b7c7d66a942708e22c07fdbd0246203a.tar.gz javassist-2cdc0275b7c7d66a942708e22c07fdbd0246203a.zip |
Fix insertAuxInitializer may cause inconsistent stack height problem
Usually, constructor only load super class's constructor's init params into stack.
After this() or super() called, stack will be empty. If so, we insertAuxInitializer
right after this() or super() can reuse max stack size if it enough.
But, there is some weird class out there, their constructors load all in-constructor
init field value into stack before this() or super() call. In this case,
after this() or super() call, stack is not empty, even maybe full.
In summary, insertAuxInitializer should increase MaxStack anyway.
-rw-r--r-- | src/main/javassist/CtClassType.java | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index 22b873a6..f4345e0a 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -1763,8 +1763,7 @@ class CtClassType extends CtClass { int pos = it.insertEx(initializer.get()); it.insert(initializer.getExceptionTable(), pos); int maxstack = codeAttr.getMaxStack(); - if (maxstack < stacksize) - codeAttr.setMaxStack(stacksize); + codeAttr.setMaxStack(maxstack + stacksize); } private int makeFieldInitializer(Bytecode code, CtClass[] parameters) |