Skip to content

Commit

Permalink
GDALMDArray::ReadUsingContiguousIRead(): avoid (valid) unsigned integ…
Browse files Browse the repository at this point in the history
…er overflow
  • Loading branch information
rouault committed Oct 7, 2023
1 parent 2cf3921 commit 78d5980
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gcore/gdalmultidim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4734,7 +4734,8 @@ bool GDALMDArray::ReadUsingContiguousIRead(
if (arrayStep[i] > 0)
anTmpStartIdx[i] = arrayStartIdx[i];
else
anTmpStartIdx[i] = arrayStartIdx[i] + (count[i] - 1) * arrayStep[i];
anTmpStartIdx[i] =
arrayStartIdx[i] - (count[i] - 1) * (-arrayStep[i]);
const uint64_t nCount =
(count[i] - 1) * static_cast<uint64_t>(std::abs(arrayStep[i])) + 1;
if (nCount > std::numeric_limits<size_t>::max() / nMemArraySize)
Expand Down

0 comments on commit 78d5980

Please sign in to comment.