From: Bad-Command Date: Wed, 4 Jul 2012 19:06:19 +0000 (-0400) Subject: Fix signed overflow in getPointedThing X-Git-Tag: 0.4.1~9 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cc10eec6c6fd6252450f7d3af098e3936e43d3d9;p=oweals%2Fminetest.git Fix signed overflow in getPointedThing --- 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++)