replace casts long to int with Math.toIntExact#1072
Merged
pjfanning merged 6 commits intoMay 14, 2026
Conversation
Merged
38d732b to
8daddeb
Compare
Merged
Replace explicit (int) casts of long values with Math.toIntExact() to detect integer overflow at runtime rather than silently truncating. Changes cover: - hemf emf records: HemfComment, HemfFill, HemfPalette, HemfDraw, HemfFont - hpsf: Section, Array, Vector, Property, PropertySet, PropertySetFactory, VariantSupport - poifs/crypt: CryptoAPIDecryptor, ChunkedCipherOutputStream, XORDecryptor, XOREncryptor - poi-ooxml XSSF: XSSFConditionalFormattingRule, XSSFDxfStyleProvider, XSSFOptimiser, XSSFChildAnchor, XSSFFontFormatting, XSSFDataBarFormatting, XSSFColor, XSSFTableStyle, XSSFWorkbook, XSSFSimpleShape, XSSFName, ColumnHelper - poi-ooxml XSLF: XSLFSimpleShape, XSLFSheet, XSLFTabStop, XSLFDrawing - poi-ooxml XDDF: XDDFDataSourcesFactory - hwpf: PlfLfo, RecordUtil - util: IOUtils - poifs/nio: ByteArrayBackedDataSource Guarded casts (already behind Integer.MAX_VALUE checks) and casts of floating-point or char values are intentionally left unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
…alette/brush indices, fix PropertySetFactory for large sectionCount Agent-Logs-Url: https://github.com/pjfanning/poi/sessions/1fcc029e-f25e-4e46-be29-fc0831ec0ee1 Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
…tySetFactory, keep (Long) cast in XSSFChildAnchor Agent-Logs-Url: https://github.com/pjfanning/poi/sessions/1fcc029e-f25e-4e46-be29-fc0831ec0ee1 Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
8daddeb to
2c952bb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
better to throw exception than to risk continuing with an int that overflows