diff --git a/OpenEXR/IlmImf/ImfTiledMisc.cpp b/OpenEXR/IlmImf/ImfTiledMisc.cpp index c9e8731f11..b8e195fd86 100644 --- a/OpenEXR/IlmImf/ImfTiledMisc.cpp +++ b/OpenEXR/IlmImf/ImfTiledMisc.cpp @@ -301,10 +301,8 @@ calculateNumTiles (int *numTiles, { for (int i = 0; i < numLevels; i++) { - int l = levelSize (min, max, i, rmode); - if (l > std::numeric_limits::max() - size + 1) - throw IEX_NAMESPACE::ArgExc ("Invalid size."); - + // use 64 bits to avoid int overflow if size is large. + Int64 l = levelSize (min, max, i, rmode); numTiles[i] = (l + size - 1) / size; } }