Fix possible integer overflow

This commit is contained in:
John Machado 2023-12-21 11:49:28 +05:30 committed by GitHub
parent f056c5d326
commit 1f69d427fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -237,7 +237,7 @@ GMM_STATUS GmmLib::GmmTextureCalc::GetTexStdLayoutOffset(GMM_TEXTURE_INFO * pT
pReqInfo->StdLayout.TileDepthPitch = DepthPitch;
}
PrevMipSize = DepthPitch * MipDepthTiles;
PrevMipSize = (GMM_GFX_SIZE_T)DepthPitch * MipDepthTiles;
SlicePitch += DepthPitch;
}
@ -352,12 +352,12 @@ GMM_STATUS GmmLib::GmmTextureCalc::GetTexLockOffset(GMM_TEXTURE_INFO * pTexInf
pReqInfo->Lock.Mip0SlicePitch = GFX_ULONG_CAST(pTexInfo->OffsetInfo.Texture3DOffsetInfo.Mip0SlicePitch);
// Actual address is offset based on requested slice
AddressOffset += SliceRow * MipHeight * Pitch;
AddressOffset += (GMM_GFX_SIZE_T)SliceRow * MipHeight * Pitch;
// Get to particular slice
if(Slice % NumberOfMipsInSingleRow)
{
AddressOffset += (((Slice % NumberOfMipsInSingleRow) *
AddressOffset += (((GMM_GFX_SIZE_T)(Slice % NumberOfMipsInSingleRow) *
MipWidth * pTexInfo->BitsPerPixel) >>
3);
}
@ -788,9 +788,9 @@ GMM_GFX_SIZE_T GmmLib::GmmTextureCalc::Get3DMipByteAddress(GMM_TEXTURE_INFO *
MipHeight /= 2;
}
ExtraBytes = PlaneRows * MipHeight * Pitch;
ExtraBytes = (GMM_GFX_SIZE_T)PlaneRows * MipHeight * Pitch;
ExtraBytes += ((Slice % MipsInThisRow) *
ExtraBytes += ((GMM_GFX_SIZE_T)(Slice % MipsInThisRow) *
MipWidth * pTexInfo->BitsPerPixel) >>
3;

View File

@ -1024,12 +1024,12 @@ GMM_STATUS GmmLib::GmmXe_LPGTextureCalc::GetTexLockOffset(GMM_TEXTURE_INFO * p
pReqInfo->Lock.Mip0SlicePitch = GFX_ULONG_CAST(pTexInfo->OffsetInfo.Texture3DOffsetInfo.Mip0SlicePitch);
// Actual address is offset based on requested slice
AddressOffset += SliceRow * MipHeight * Pitch;
AddressOffset += (GMM_GFX_SIZE_T)SliceRow * MipHeight * Pitch;
// Get to particular slice
if(Slice % NumberOfMipsInSingleRow)
{
AddressOffset += (((Slice % NumberOfMipsInSingleRow) *
AddressOffset += (((GMM_GFX_SIZE_T)(Slice % NumberOfMipsInSingleRow) *
MipWidth * pTexInfo->BitsPerPixel) >>
3);
}