Skip to content

Commit

Permalink
Fix reading of short values from constant pool table (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehutch committed Aug 14, 2021
1 parent 984d35c commit e0557fe
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/main/java/io/github/classgraph/Classfile.java
Expand Up @@ -824,24 +824,6 @@ private boolean constantPoolStringEquals(final int cpIdx, final String asciiStr)

// -------------------------------------------------------------------------------------------------------------

/**
* Read an unsigned short from the constant pool.
*
* @param cpIdx
* the constant pool index.
* @return the unsigned short
* @throws IOException
* If an I/O exception occurred.
*/
private int cpReadUnsignedShort(final int cpIdx) throws IOException {
if (cpIdx < 1 || cpIdx >= cpCount) {
throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, "
+ (cpCount - 1) + "] -- cannot continue reading class. "
+ "Please report this at https://github.com/classgraph/classgraph/issues");
}
return reader.readUnsignedShort(entryOffset[cpIdx]);
}

/**
* Read an int from the constant pool.
*
Expand Down Expand Up @@ -985,7 +967,7 @@ private Object readAnnotationElementValue() throws IOException {
case 'J':
return cpReadLong(reader.readUnsignedShort());
case 'S':
return (short) cpReadUnsignedShort(reader.readUnsignedShort());
return (short) cpReadInt(reader.readUnsignedShort());
case 'Z':
return cpReadInt(reader.readUnsignedShort()) != 0;
case 's':
Expand Down

0 comments on commit e0557fe

Please sign in to comment.