[GRASS-SVN] r71273 - grass/trunk/raster/r.viewshed

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 17 13:45:55 PDT 2017


Author: mmetz
Date: 2017-07-17 13:45:55 -0700 (Mon, 17 Jul 2017)
New Revision: 71273

Modified:
   grass/trunk/raster/r.viewshed/viewshed.cpp
Log:
r.viewshed: avoid integer overflow

Modified: grass/trunk/raster/r.viewshed/viewshed.cpp
===================================================================
--- grass/trunk/raster/r.viewshed/viewshed.cpp	2017-07-17 20:29:55 UTC (rev 71272)
+++ grass/trunk/raster/r.viewshed/viewshed.cpp	2017-07-17 20:45:55 UTC (rev 71273)
@@ -151,8 +151,10 @@
     }
     else {
 	/* this is the max value of size_t */
-	long long maxsizet = ((long long)1 << (sizeof(size_t) * 8)) - 1;
+	long long maxsizet = ((long long)1 << (sizeof(size_t) * 8 - 2)) - 1;
 
+	maxsizet += ((long long)1 << (sizeof(size_t) * 8 - 2));
+
 	G_debug(1, "max size_t is %lld", maxsizet);
 
 	/* checking whether allocating totalsize causes an overflow */



More information about the grass-commit mailing list