Merge pull request #127 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / util / InternalUtils.java
index f26c2ae06daa140816fdb9cb16da1d6aecedcb86..4e706ec10d24d232505a555533a544d3e89a6373 100644 (file)
@@ -2,7 +2,14 @@ package org.ldk.util;
 
 public class InternalUtils {
     public static byte[] check_arr_len(byte[] arr, int length) throws IllegalArgumentException {
-        if (arr.length != length) {
+        if (arr != null && arr.length != length) {
+            throw new IllegalArgumentException("Array must be of fixed size " + length + " but was of length " + arr.length);
+        }
+        return arr;
+    }
+
+    public static short[] check_arr_16_len(short[] arr, int length) throws IllegalArgumentException {
+        if (arr != null && arr.length != length) {
             throw new IllegalArgumentException("Array must be of fixed size " + length + " but was of length " + arr.length);
         }
         return arr;