Skip to content

Commit 8d12298

Browse files
MarkLee131neheb
authored andcommitted
Use integer division in TiffBinaryArray::doCount
doCount() uses std::lround(double(size) / typeSize) which rounds to the nearest integer. When size is not a multiple of typeSize, this can round up and report more elements than the data holds. On re-read, the inflated count causes the parser to expect more data than exists. Use integer division instead, which truncates and is consistent with how readTiffEntry computes size from count and typeSize.
1 parent 8f5d23c commit 8d12298

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/tiffcomposite_int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ size_t TiffBinaryArray::doCount() const {
795795
typeSize = 1;
796796
}
797797

798-
return std::lround(static_cast<double>(size()) / typeSize);
798+
return size() / typeSize;
799799
}
800800

801801
size_t TiffBinaryElement::doCount() const {

0 commit comments

Comments
 (0)