Fix issue #318015.
diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckFrameAnalyzer.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckFrameAnalyzer.java
index c693df9..b58398c 100644
--- a/asm-util/src/main/java/org/objectweb/asm/util/CheckFrameAnalyzer.java
+++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckFrameAnalyzer.java
@@ -123,7 +123,7 @@
}
Frame<V>[] frames = getFrames();
- Frame<V> currentFrame = frames[0];
+ Frame<V> currentFrame = newFrame(frames[0]);
expandFrames(owner, method, currentFrame);
for (int insnIndex = 0; insnIndex < insnList.size(); ++insnIndex) {
Frame<V> oldFrame = frames[insnIndex];
diff --git a/asm-util/src/test/java/org/objectweb/asm/util/CheckFrameAnalyzerTest.java b/asm-util/src/test/java/org/objectweb/asm/util/CheckFrameAnalyzerTest.java
index 154ea29..bc8aa0d 100644
--- a/asm-util/src/test/java/org/objectweb/asm/util/CheckFrameAnalyzerTest.java
+++ b/asm-util/src/test/java/org/objectweb/asm/util/CheckFrameAnalyzerTest.java
@@ -27,6 +27,7 @@
// THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.util;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -64,6 +65,22 @@
private final Label label0 = new Label();
@Test
+ void testAnalyze_validBytecode() {
+ MethodNode methodNode =
+ new MethodNodeBuilder("(Ljava/lang/Object;)V", 1, 2)
+ .aload(0)
+ .astore(1)
+ .iconst_0()
+ .istore(0)
+ .vreturn()
+ .build();
+
+ Executable analyze = () -> newAnalyzer().analyze(CLASS_NAME, methodNode);
+
+ assertDoesNotThrow(analyze);
+ }
+
+ @Test
void testAnalyze_invalidJsr() {
MethodNode methodNode = new MethodNodeBuilder().jsr(label0).label(label0).vreturn().build();
diff --git a/asm-util/src/test/java/org/objectweb/asm/util/MethodNodeBuilder.java b/asm-util/src/test/java/org/objectweb/asm/util/MethodNodeBuilder.java
index 33c369e..1d2b6ee 100644
--- a/asm-util/src/test/java/org/objectweb/asm/util/MethodNodeBuilder.java
+++ b/asm-util/src/test/java/org/objectweb/asm/util/MethodNodeBuilder.java
@@ -47,7 +47,11 @@
}
MethodNodeBuilder(final int maxStack, final int maxLocals) {
- methodNode = new MethodNode(Opcodes.ACC_PUBLIC, "m", "()V", null, null);
+ this("()V", maxStack, maxLocals);
+ }
+
+ MethodNodeBuilder(final String descriptor, final int maxStack, final int maxLocals) {
+ methodNode = new MethodNode(Opcodes.ACC_PUBLIC, "m", descriptor, null, null);
methodNode.maxStack = maxStack;
methodNode.maxLocals = maxLocals;
methodNode.visitCode();
@@ -63,6 +67,21 @@
return this;
}
+ MethodNodeBuilder istore(final int variable) {
+ methodNode.visitVarInsn(Opcodes.ISTORE, variable);
+ return this;
+ }
+
+ MethodNodeBuilder aload(final int variable) {
+ methodNode.visitVarInsn(Opcodes.ALOAD, variable);
+ return this;
+ }
+
+ MethodNodeBuilder astore(final int variable) {
+ methodNode.visitVarInsn(Opcodes.ASTORE, variable);
+ return this;
+ }
+
MethodNodeBuilder vreturn() {
methodNode.visitInsn(Opcodes.RETURN);
return this;