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 a42f8a7502954a67b8fa69f109494cabf0012817
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Fri Feb 6 12:03:48 2026 +0100

    Safety against a possible integer overflow.
    Safety against precision loss.
---
 .../main/org/apache/sis/io/stream/ChannelDataInput.java               | 2 +-
 .../main/org/apache/sis/util/internal/shared/Numerics.java            | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/ChannelDataInput.java
 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/ChannelDataInput.java
index e2e8ed9dec..bb819a57e4 100644
--- 
a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/ChannelDataInput.java
+++ 
b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/io/stream/ChannelDataInput.java
@@ -703,7 +703,7 @@ public class ChannelDataInput extends ChannelData 
implements DataInput {
         @Override
         void readFully(Buffer view, int offset, int length) throws IOException 
{
             final int dataSizeShift = dataSizeShift();
-            ensureBufferContains(Math.min(length << dataSizeShift, 
buffer.capacity()));
+            ensureBufferContains((int) Math.min(((long) length) << 
dataSizeShift, buffer.capacity()));
             if (view == null) {
                 view = createView();                                    // 
Must be after ensureBufferContains(int).
             } else {
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/Numerics.java
 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/Numerics.java
index a7bdbc308f..2a584b08d5 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/Numerics.java
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/internal/shared/Numerics.java
@@ -313,7 +313,7 @@ public final class Numerics {
 
     /**
      * Returns the given fraction as a {@link Fraction} instance if possible,
-     * or as a {@link Double} approximation otherwise.
+     * or as a {@link DoubleDouble} approximation otherwise.
      *
      * @param  numerator    numerator of the fraction to return.
      * @param  denominator  denominator of the fraction to return.
@@ -323,7 +323,7 @@ public final class Numerics {
         try {
             return Fraction.valueOf(numerator, denominator);
         } catch (ArithmeticException e) {
-            return numerator / (double) denominator;
+            return 
DoubleDouble.of(numerator).divide(DoubleDouble.of(denominator));
         }
     }
 

Reply via email to