You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/21 21:07:12 UTC
[commons-bcel] 01/02: org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
commit d846b81d65af43d8b42f6086903f1c4eedd69db6
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Mon Nov 21 13:54:16 2022 -0500
org.apache.bcel.classfile.LocalVariable constructors now throw
ClassFormatException on invalid input
---
src/changes/changes.xml | 1 +
.../org/apache/bcel/classfile/LocalVariable.java | 24 ++++++++--------------
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 876c0384..25c0b667 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -103,6 +103,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ExceptionTable constructors now throw ClassFormatException on invalid input.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.InnerClasses constructors now throw ClassFormatException on invalid input.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LineNumber constructors now throw ClassFormatException on invalid input.</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.LocalVariable constructors now throw ClassFormatException on invalid input.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump spotbugs-maven-plugin from 4.7.2.2 to 4.7.3.0 #167.</action>
<action type="update" dev="ggregory" due-to="Dependabot">Bump jmh.version from 1.35 to 1.36 #170.</action>
diff --git a/src/main/java/org/apache/bcel/classfile/LocalVariable.java b/src/main/java/org/apache/bcel/classfile/LocalVariable.java
index c3d64bf7..25216929 100644
--- a/src/main/java/org/apache/bcel/classfile/LocalVariable.java
+++ b/src/main/java/org/apache/bcel/classfile/LocalVariable.java
@@ -21,6 +21,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.bcel.Constants;
+import org.apache.bcel.util.Args;
/**
* This class represents a local variable within a method. It contains its scope, name, signature and index on the
@@ -46,7 +47,7 @@ public final class LocalVariable implements Cloneable, Node, Constants {
* Variable is index'th local variable on this method's frame.
*/
private ConstantPool constantPool;
- private int origIndex; // never changes; used to match up with LocalVariableTypeTable entries
+ private final int origIndex; // never changes; used to match up with LocalVariableTypeTable entries
/**
* Constructs object from file stream.
@@ -67,13 +68,7 @@ public final class LocalVariable implements Cloneable, Node, Constants {
* @param constantPool Array of constants
*/
public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool) {
- this.startPc = startPc;
- this.length = length;
- this.nameIndex = nameIndex;
- this.signatureIndex = signatureIndex;
- this.index = index;
- this.constantPool = constantPool;
- this.origIndex = index;
+ this(startPc, length, nameIndex, signatureIndex, index, constantPool, index);
}
/**
@@ -87,13 +82,13 @@ public final class LocalVariable implements Cloneable, Node, Constants {
*/
public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool,
final int origIndex) {
- this.startPc = startPc;
- this.length = length;
- this.nameIndex = nameIndex;
- this.signatureIndex = signatureIndex;
- this.index = index;
+ this.startPc = Args.requireU2(startPc, "startPc");
+ this.length = Args.requireU2(length, "length");
+ this.nameIndex = Args.requireU2(nameIndex, "nameIndex");
+ this.signatureIndex = Args.requireU2(signatureIndex, "signatureIndex");
+ this.index = Args.requireU2(index, "index");
+ this.origIndex = Args.requireU2(origIndex, "origIndex");
this.constantPool = constantPool;
- this.origIndex = origIndex;
}
/**
@@ -105,7 +100,6 @@ public final class LocalVariable implements Cloneable, Node, Constants {
public LocalVariable(final LocalVariable localVariable) {
this(localVariable.getStartPC(), localVariable.getLength(), localVariable.getNameIndex(), localVariable.getSignatureIndex(), localVariable.getIndex(),
localVariable.getConstantPool());
- this.origIndex = localVariable.getOrigIndex();
}
/**