Skip to content

Commit d2215d5

Browse files
committed
Base32 constructor fails-fast with a NullPointerException if the custom
alphabet array is null
1 parent fcc70e6 commit d2215d5

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/changes/changes.xml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
4949
<action type="fix" dev="ggregory" due-to="Gary Gregory">Optimize memory allocation in PhoneticEngine.</action>
5050
<action type="fix" dev="ggregory" due-to="Gary Gregory">BCodec and QCodec encode() methods throw UnsupportedCharsetException instead of EncoderException.</action>
5151
<action type="fix" dev="ggregory" due-to="Gary Gregory">Set Javadoc link to latest Java API LTS version.</action>
52+
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base32 constructor fails-fast with a NullPointerException if the custom alphabet array is null.</action>
5253
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base32 constructor makes a defensive copy of the line separator array.</action>
5354
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base64 constructor makes a defensive copy of the line separator array.</action>
5455
<action type="fix" dev="ggregory" due-to="Gary Gregory">Base64 constructor makes a defensive copy of a custom alphabet array.</action>

src/main/java/org/apache/commons/codec/binary/Base32.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.commons.codec.binary;
1919

20+
import java.util.Objects;
21+
2022
import org.apache.commons.codec.CodecPolicy;
2123

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

0 commit comments

Comments
 (0)