Skip to content

Commit

Permalink
GTiff: CacheMultiRange(): properly react to errors in VSIFReadMultiRa…
Browse files Browse the repository at this point in the history
…ngeL()

Fixes #11552
  • Loading branch information
rouault authored and github-actions[bot] committed Jan 4, 2025
1 parent 5f29238 commit 9b921b8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions frmts/gtiff/gtiffrasterband_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,17 @@ void *GTiffRasterBand::CacheMultiRange(int nXOff, int nYOff, int nXSize,

VSILFILE *fp = VSI_TIFFGetVSILFile(th);

if (VSIFReadMultiRangeL(static_cast<int>(anSizes.size()),
// An error in VSIFReadMultiRangeL() will not be criticial,
// as this method is an optimization, and if it fails,
// tile-by-tile data acquisition will be done, so we can
// temporary turn failures into warnings.
CPLTurnFailureIntoWarning(true);
const bool ok =
VSIFReadMultiRangeL(static_cast<int>(anSizes.size()),
&apData[0], &anOffsets[0], &anSizes[0],
fp) == 0)
fp) == 0;
CPLTurnFailureIntoWarning(false);
if (ok)
{
if (!oMapStrileToOffsetByteCount.empty() &&
!FillCacheStrileToOffsetByteCount(anOffsets, anSizes,
Expand All @@ -1062,6 +1070,11 @@ void *GTiffRasterBand::CacheMultiRange(int nXOff, int nYOff, int nXSize,
th, static_cast<int>(anSizes.size()), &apData[0],
&anOffsets[0], &anSizes[0]);
}
else
{
CPLFree(pBufferedData);
pBufferedData = nullptr;
}
}
}
}
Expand Down

0 comments on commit 9b921b8

Please sign in to comment.