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/27 23:04:25 UTC

[commons-bcel] branch master updated (be4aec1b -> 2eb97367)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


    from be4aec1b Use an inline comment
     new ce634b1e Fix compiler warning
     new 2eb97367 Fix possible NullPointerException in org.apache.bcel.classfile.StackMap.setStackMap(StackMapEntry[])

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                                   |  1 +
 src/main/java/org/apache/bcel/classfile/StackMap.java     |  2 +-
 .../bcel/verifier/structurals/InstConstraintVisitor.java  | 15 +++++++--------
 3 files changed, 9 insertions(+), 9 deletions(-)


[commons-bcel] 01/02: Fix compiler warning

Posted by gg...@apache.org.
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 ce634b1e3e7c3c5dc6cad31d832da666240f023e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 27 18:02:20 2022 -0500

    Fix compiler warning
    
    Could not be an NPE previously anyway
---
 .../bcel/verifier/structurals/InstConstraintVisitor.java  | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
index d4ec88b5..1c92576d 100644
--- a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
+++ b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
@@ -943,19 +943,18 @@ public class InstConstraintVisitor extends EmptyVisitor {
             shouldBe = Type.INT;
         }
         if (t instanceof ReferenceType) {
-            ReferenceType rValue = null;
             if (value instanceof ReferenceType) {
-                rValue = (ReferenceType) value;
+                ReferenceType rValue = (ReferenceType) value;
                 referenceTypeIsInitialized(o, rValue);
+                // TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
+                // using "wider cast object types" created during verification.
+                // Comment it out if you encounter problems. See also the analogon at visitPUTFIELD|visitPUTSTATIC.
+                if (!rValue.isAssignmentCompatibleWith(shouldBe)) {
+                    constraintViolated(o, "The stack top type '" + value + "' is not assignment compatible with '" + shouldBe + "'.");
+                }
             } else {
                 constraintViolated(o, "The stack top type '" + value + "' is not of a reference type as expected.");
             }
-            // TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
-            // using "wider cast object types" created during verification.
-            // Comment it out if you encounter problems. See also the analogon at visitPUTFIELD|visitPUTSTATIC.
-            if (!rValue.isAssignmentCompatibleWith(shouldBe)) {
-                constraintViolated(o, "The stack top type '" + value + "' is not assignment compatible with '" + shouldBe + "'.");
-            }
         } else if (shouldBe != value) {
             constraintViolated(o, "The stack top type '" + value + "' is not of type '" + shouldBe + "' as expected.");
         }


[commons-bcel] 02/02: Fix possible NullPointerException in org.apache.bcel.classfile.StackMap.setStackMap(StackMapEntry[])

Posted by gg...@apache.org.
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 2eb9736750fb884db269e7e52533295074830074
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 27 18:04:21 2022 -0500

    Fix possible NullPointerException in
    org.apache.bcel.classfile.StackMap.setStackMap(StackMapEntry[])
---
 src/changes/changes.xml                               | 1 +
 src/main/java/org/apache/bcel/classfile/StackMap.java | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index aab0029b..7c4c9eec 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -114,6 +114,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="fix" dev="markt" due-to="OSS-Fuzz">When parsing class files, limit arrays to no more than 255 dimensions as per section 4.4.1 of the JVM specification.</action>
       <action                  type="fix" dev="ggregory" due-to="nbauma109">Tests and coverage for Utility class #175.</action>
       <action                  type="fix" dev="ggregory" due-to="nbauma109">Unit tests and coverage for binary operations #174.</action>
+      <action                  type="fix" dev="ggregory" due-to="Gary Gregory">Fix possible NullPointerException in org.apache.bcel.classfile.StackMap.setStackMap(StackMapEntry[]).</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/StackMap.java b/src/main/java/org/apache/bcel/classfile/StackMap.java
index 80f2d2a7..40df561d 100644
--- a/src/main/java/org/apache/bcel/classfile/StackMap.java
+++ b/src/main/java/org/apache/bcel/classfile/StackMap.java
@@ -135,7 +135,7 @@ public final class StackMap extends Attribute {
     public void setStackMap(final StackMapEntry[] table) {
         this.table = table != null ? table : StackMapEntry.EMPTY_ARRAY;
         int len = 2; // Length of 'number_of_entries' field prior to the array of stack maps
-        for (final StackMapEntry element : table) {
+        for (final StackMapEntry element : this.table) {
             len += element.getMapEntrySize();
         }
         setLength(len);