Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/org/apache/xmlbeans/impl/util/HexBin.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public final class HexBin {
* byte to be tested if it is Base64 alphabet
*/
static boolean isHex(byte octect) {
return (hexNumberTable[octect] != -1);
// byte is a signed type and [] operator takes an int as an index.
// If use `octect` directly, negative byte will be promoted to the
// negative int and ArrayIndexOutOfBoundException will be thrown.
// `& 0xFF` will convert negative byte to positive int
return (hexNumberTable[octect & 0xFF] != -1);
}

/**
Expand Down