From c2bcc5d9dfb48cb233a325dd1d72b5983b5153fe Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Fri, 11 Oct 2024 09:50:45 -0400 Subject: [PATCH] fix bug in KDTreeUtils unflatten() threw an ArrayIndexOutOfBoundsException for the following use-case: // input: [1.0, 1.0, 1.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 1.0], dim=2 // the should-be result with the fix deep: [[1.0, 1.0, 1.0, 0.0, 0.0], [1.0, 0.0, 0.5, 0.0, 1.0]] // without the fix java.lang.ArrayIndexOutOfBoundsException: 5 at net.imglib2.kdtree.KDTreeUtils.unflatten(KDTreeUtils.java:229) --- src/main/java/net/imglib2/kdtree/KDTreeUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/imglib2/kdtree/KDTreeUtils.java b/src/main/java/net/imglib2/kdtree/KDTreeUtils.java index e60ee2014..2f937912a 100644 --- a/src/main/java/net/imglib2/kdtree/KDTreeUtils.java +++ b/src/main/java/net/imglib2/kdtree/KDTreeUtils.java @@ -226,7 +226,7 @@ static double[][] unflatten( double[] positions, final int n ) for (int i = 0; i < positions.length; ++i ) { final int d = i % n; - unflattened[ d ][ i / n + d ] = positions[ i ]; + unflattened[ d ][ i / n ] = positions[ i ]; } return unflattened;