Skip to content

Commit

Permalink
Base32 constructor fails-fast with a NullPointerException if the custom
Browse files Browse the repository at this point in the history
alphabet array is null
  • Loading branch information
garydgregory committed Apr 20, 2024
1 parent fcc70e6 commit d2215d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Optimize memory allocation in PhoneticEngine.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">BCodec and QCodec encode() methods throw UnsupportedCharsetException instead of EncoderException.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Set Javadoc link to latest Java API LTS version.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base32 constructor fails-fast with a NullPointerException if the custom alphabet array is null.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base32 constructor makes a defensive copy of the line separator array.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base64 constructor makes a defensive copy of the line separator array.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base64 constructor makes a defensive copy of a custom alphabet array.</action>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/apache/commons/codec/binary/Base32.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.commons.codec.binary;

import java.util.Objects;

import org.apache.commons.codec.CodecPolicy;

/**
Expand Down Expand Up @@ -353,6 +355,7 @@ public Base32(final int lineLength, final byte[] lineSeparator, final boolean us
*/
private Base32(final int lineLength, final byte[] lineSeparator, final byte[] encodeTable, final byte padding, final CodecPolicy decodingPolicy) {
super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, toLength(lineSeparator), padding, decodingPolicy);
Objects.requireNonNull(encodeTable, "encodeTable");
this.encodeTable = encodeTable;
this.decodeTable = encodeTable == HEX_ENCODE_TABLE ? HEX_DECODE_TABLE : DECODE_TABLE;
if (lineLength > 0) {
Expand Down

0 comments on commit d2215d5

Please sign in to comment.