You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2019/01/08 15:12:21 UTC

[sis] 02/02: Fix an erroneous assertion and a NullPointerException.

This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit b68592ec612ae6ec74d35159dbe904b8cdecc76a
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Jan 8 16:11:56 2019 +0100

    Fix an erroneous assertion and a NullPointerException.
---
 .../java/org/apache/sis/internal/raster/ColorModelFactory.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/sis-raster/src/main/java/org/apache/sis/internal/raster/ColorModelFactory.java b/core/sis-raster/src/main/java/org/apache/sis/internal/raster/ColorModelFactory.java
index 281b8b5..19fca25 100644
--- a/core/sis-raster/src/main/java/org/apache/sis/internal/raster/ColorModelFactory.java
+++ b/core/sis-raster/src/main/java/org/apache/sis/internal/raster/ColorModelFactory.java
@@ -184,8 +184,8 @@ public final class ColorModelFactory {
         }
         this.minimum     = (float) minimum;
         this.maximum     = (float) maximum;
-        this.pieceStarts = starts;
-        this.ARGB        = codes;
+        this.pieceStarts = ArraysExt.resize(starts, count + 1);
+        this.ARGB        = ArraysExt.resize(codes,  count);
     }
 
     /**
@@ -394,10 +394,10 @@ public final class ColorModelFactory {
      * @return the number of bits to use.
      */
     public static int getBitCount(final int mapSize) {
-        final int count = Math.max(1, Integer.SIZE - Integer.numberOfLeadingZeros(mapSize - 1));
+        final int count = Integer.SIZE - Integer.numberOfLeadingZeros(mapSize - 1);
         assert (1 << count) >= mapSize : mapSize;
         assert (1 << (count-1)) < mapSize : mapSize;
-        return count;
+        return Math.max(1, count);
     }
 
     /**