sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 03/03: Fix a NullPointerException when sample values have integers greater than 65535.
Date Thu, 21 Feb 2019 15:03:27 GMT
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 e59aac9daa9de8d5ec1c62048b4846f35185a37a
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Feb 21 15:25:47 2019 +0100

    Fix a NullPointerException when sample values have integers greater than 65535.
---
 .../java/org/apache/sis/internal/raster/ColorModelFactory.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 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 19fca25..c392831 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
@@ -42,6 +42,7 @@ import org.apache.sis.util.collection.WeakValueHashMap;
  * A factory for {@link ColorModel} objects built from a sequence of colors.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @author  Johann Sorel (Geomatys)
  * @version 1.0
  * @since   1.0
  * @module
@@ -155,9 +156,10 @@ public final class ColorModelFactory {
             final int lower = Math.round((float) min);
             final int upper = Math.round((float) max);
             if (lower < upper) {
-                if (lower < 0 || upper > 0xFFFF) {
+                if (lower < 0 || upper > 0x10000) {
                     starts = ArraysExt.EMPTY_SHORT;
                     codes  = null;
+                    count  = 0;
                 } else if (codes != null) {
                     if (count != 0) {
                         final int before = Short.toUnsignedInt(starts[count]);
@@ -182,9 +184,12 @@ public final class ColorModelFactory {
             minimum = 0;
             maximum = 1;
         }
+        if (starts.length != 0) {
+            starts = ArraysExt.resize(starts, count + 1);
+        }
         this.minimum     = (float) minimum;
         this.maximum     = (float) maximum;
-        this.pieceStarts = ArraysExt.resize(starts, count + 1);
+        this.pieceStarts = starts;
         this.ARGB        = ArraysExt.resize(codes,  count);
     }
 


Mime
View raw message