Skip to content

Commit 47c9b59

Browse files
committed
VRTComplexSource::RasterIOProcessNoData(): avoid potential assertion on 32-bit builds on huge mem allocations (fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66644)
1 parent 7967a18 commit 47c9b59

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

frmts/vrt/vrtsources.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,9 @@ CPLErr VRTComplexSource::RasterIOProcessNoData(
30103010
// Cannot overflow since pData should at least have that number of
30113011
// elements
30123012
const size_t nPixelCount = static_cast<size_t>(nOutXSize) * nOutYSize;
3013-
if (nPixelCount > std::numeric_limits<size_t>::max() / sizeof(SourceDT))
3013+
if (nPixelCount >
3014+
static_cast<size_t>(std::numeric_limits<ptrdiff_t>::max()) /
3015+
sizeof(SourceDT))
30143016
{
30153017
CPLError(CE_Failure, CPLE_OutOfMemory,
30163018
"Too large temporary buffer");
@@ -3226,8 +3228,9 @@ CPLErr VRTComplexSource::RasterIOInternal(
32263228
{
32273229
// Cannot overflow since pData should at least have that number of
32283230
// elements
3229-
if (nPixelCount > std::numeric_limits<size_t>::max() /
3230-
static_cast<size_t>(nWordSize))
3231+
if (nPixelCount >
3232+
static_cast<size_t>(std::numeric_limits<ptrdiff_t>::max()) /
3233+
static_cast<size_t>(nWordSize))
32313234
{
32323235
CPLError(CE_Failure, CPLE_OutOfMemory,
32333236
"Too large temporary buffer");

0 commit comments

Comments
 (0)