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

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

commit e6d4b3e54d972266a3dc04ca918b28345cd9c642
Author: jsorel <[email protected]>
AuthorDate: Thu Oct 29 10:06:50 2026 +0100

    fix(DGGRS): detect incorrect subzone count and raise an exception
---
 .../sis/storage/dggs/DiscreteGlobalGridTransform.java     | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/dggs/DiscreteGlobalGridTransform.java
 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/dggs/DiscreteGlobalGridTransform.java
index e146a0ea2e..5dfee9a574 100644
--- 
a/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/dggs/DiscreteGlobalGridTransform.java
+++ 
b/incubator/src/org.apache.sis.referencing.dggs/main/org/apache/sis/storage/dggs/DiscreteGlobalGridTransform.java
@@ -206,7 +206,7 @@ public abstract class DiscreteGlobalGridTransform extends 
SubTransform {
             if (zids != null) return;
 
             final DiscreteGlobalGridHierarchy dggh = 
dggrs.getGridSystem().getHierarchy();
-            zids = new Object[(int) extent.getSize(0)];
+            final Object[] array = new Object[(int) extent.getSize(0)];
             final Zone zone = dggh.getZone(baseZoneIds[0]);
             final int searchedLevel = 
zone.getLocationType().getRefinementLevel() + relativeDepth;
             int idx = 0;
@@ -214,11 +214,22 @@ public abstract class DiscreteGlobalGridTransform extends 
SubTransform {
                 Iterator<Object> iterator = s.iterator();
                 while (iterator.hasNext()) {
                     Object zid = iterator.next();
-                    zids[idx] = zid;
+                    if (idx >= array.length) {
+                        index.clear();
+                        throw new TransformException("Zone " + baseZoneIds[0] 
+ " declares " + array.length
+                                + " children at relative depth " + 
relativeDepth + " but the grid returned more.");
+                    }
+                    array[idx] = zid;
                     index.put(zid, idx);
                     idx++;
                 }
             }
+            if (idx != array.length) {
+                index.clear();
+                throw new TransformException("Zone " + baseZoneIds[0] + " 
declares " + array.length
+                        + " children at relative depth " + relativeDepth + " 
but the grid returned " + idx + ".");
+            }
+            zids = array;
         }
 
         @Override

Reply via email to