Skip to content

Commit

Permalink
r.viewshed: Avoid integer overflow (#1275)
Browse files Browse the repository at this point in the history
Fixes -Winteger-overflow compiler warning.
  • Loading branch information
nilason committed Feb 10, 2021
1 parent 7f575a0 commit dc5e3db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions raster/r.viewshed/viewshed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ AEvent *allocate_eventlist(GridHeader * hd)
}
else {
/* this is the max value of size_t */
long long maxsizet = ((long long)1 << (sizeof(size_t) * 8 - 1)) - 1;
long long m = ((long long)1 << (sizeof(size_t) * 8 - 1)),
maxsizet = m - 1;

maxsizet += ((long long)1 << (sizeof(size_t) * 8 - 1));
maxsizet += m;

G_debug(1, "max size_t is %lld", maxsizet);

Expand Down

0 comments on commit dc5e3db

Please sign in to comment.