aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBad-Command <Corey.Edmunds@gmail.com>2012-07-04 15:06:19 -0400
committerPerttu Ahola <celeron55@gmail.com>2012-07-21 16:13:51 +0300
commitcc10eec6c6fd6252450f7d3af098e3936e43d3d9 (patch)
tree097f1e187b8d37c0abc0efee674c95ee6f7356e8
parent15bf9a7026db34bddc5f756361bd06a1e5cb9aff (diff)
downloadminetest-cc10eec6c6fd6252450f7d3af098e3936e43d3d9.tar.gz
minetest-cc10eec6c6fd6252450f7d3af098e3936e43d3d9.tar.bz2
minetest-cc10eec6c6fd6252450f7d3af098e3936e43d3d9.zip
Fix signed overflow in getPointedThing
-rw-r--r--src/game.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index e2e6dd8c1..347dbf44b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -367,6 +367,14 @@ PointedThing getPointedThing(Client *client, v3f player_position,
s16 zend = pos_i.Z + (camera_direction.Z>0 ? a : 1);
s16 xend = pos_i.X + (camera_direction.X>0 ? a : 1);
+ // Prevent signed number overflow
+ if(yend==32767)
+ yend=32766;
+ if(zend==32767)
+ zend=32766;
+ if(xend==32767)
+ xend=32766;
+
for(s16 y = ystart; y <= yend; y++)
for(s16 z = zstart; z <= zend; z++)
for(s16 x = xstart; x <= xend; x++)