mirror of https://github.com/apache/poi.git
use ArithmeticUtils for calculations that might overflow
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1857594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8a1d0151ea
commit
3c7bb45e54
|
@ -36,6 +36,7 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.math3.util.ArithmeticUtils;
|
||||
import org.apache.poi.EmptyFileException;
|
||||
import org.apache.poi.poifs.common.POIFSBigBlockSize;
|
||||
import org.apache.poi.poifs.common.POIFSConstants;
|
||||
|
@ -407,7 +408,8 @@ public class POIFSFileSystem extends BlockStore
|
|||
newBAT.setOurBlockIndex(offset);
|
||||
// Ensure there's a spot in the file for it
|
||||
ByteBuffer buffer = ByteBuffer.allocate(bigBlockSize.getBigBlockSize());
|
||||
int writeTo = (1 + offset) * bigBlockSize.getBigBlockSize(); // Header isn't in BATs
|
||||
// Header isn't in BATs
|
||||
long writeTo = ArithmeticUtils.mulAndCheck((1 + (long)offset), (long)bigBlockSize.getBigBlockSize());
|
||||
_data.write(buffer, writeTo);
|
||||
// All done
|
||||
return newBAT;
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TempFilePOIFSFileSystem extends POIFSFileSystem {
|
|||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (tempFile != null) tempFile.delete();
|
||||
if (tempFile != null && tempFile.exists()) tempFile.delete();
|
||||
super.close();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue