aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/ss/util/cellwalk
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2019-04-15 16:02:53 +0000
committerPJ Fanning <fanningpj@apache.org>2019-04-15 16:02:53 +0000
commitc56ebe15af2059bacf6e01f71e927b5065ccc197 (patch)
treeb6ed13175296bee613f6848a523dd6cfe3760603 /src/java/org/apache/poi/ss/util/cellwalk
parent3c7bb45e54f3bb07a8b9b71c3cd780bf3ab2df1d (diff)
downloadpoi-c56ebe15af2059bacf6e01f71e927b5065ccc197.tar.gz
poi-c56ebe15af2059bacf6e01f71e927b5065ccc197.zip
use ArithmeticUtils for calculations that might overflow
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1857596 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/ss/util/cellwalk')
-rw-r--r--src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java b/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
index fe1605ce30..9ab0e530fc 100644
--- a/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
+++ b/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
@@ -17,6 +17,7 @@
package org.apache.poi.ss.util.cellwalk;
+import org.apache.commons.math3.util.ArithmeticUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
@@ -91,9 +92,10 @@ public class CellWalk {
continue;
}
- ctx.ordinalNumber =
- (ctx.rowNumber - firstRow) * width +
- (ctx.colNumber - firstColumn + 1);
+ long rowSize = ArithmeticUtils.mulAndCheck(
+ (long)ArithmeticUtils.subAndCheck(ctx.rowNumber, firstRow), (long)width);
+
+ ctx.ordinalNumber = ArithmeticUtils.addAndCheck(rowSize, (ctx.colNumber - firstColumn + 1));
handler.onCell(currentCell, ctx);
}