Skip to content

Commit

Permalink
Avoid integer overflow when calculating length
Browse files Browse the repository at this point in the history
It may happen that the product of the two 4-byte integers overflows
before assigning to the 8-byte integer. We need to explicitly convert to
8 bytes first before multiplying.
  • Loading branch information
terminationshock committed Feb 25, 2022
1 parent f9e0327 commit 3dce2ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mpifx_win.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contains

local_length = 0
if (mycomm%lead) then
local_length = length * disp_unit
local_length = int(length, kind=MPI_ADDRESS_KIND) * disp_unit
end if

call mpi_win_allocate_shared(local_length, disp_unit, MPI_INFO_NULL, mycomm%id, baseptr, self%id, error0)
Expand Down

0 comments on commit 3dce2ea

Please sign in to comment.