From: divverent Date: Tue, 3 Jul 2007 21:28:39 +0000 (+0000) Subject: fix brushforbox_index integer overflow found by Green - thanks for reporting. And... X-Git-Tag: xonotic-v0.1.0preview~3000 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d7badd35c6597f09c7c13fc1d6b4217b0d9773bb;p=xonotic%2Fdarkplaces.git fix brushforbox_index integer overflow found by Green - thanks for reporting. And C's modulo operation sucks. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7464 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/collision.c b/collision.c index 7bfc9c25..94c39843 100644 --- a/collision.c +++ b/collision.c @@ -1002,7 +1002,9 @@ void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t #define MAX_BRUSHFORBOX 16 -static int brushforbox_index = 0; +static unsigned int brushforbox_index = 0; +// note: this relies on integer overflow to be consistent with modulo +// MAX_BRUSHFORBOX, or in other words, MAX_BRUSHFORBOX must be a power of two! static colpointf_t brushforbox_point[MAX_BRUSHFORBOX*8]; static colplanef_t brushforbox_plane[MAX_BRUSHFORBOX*6]; static colbrushf_t brushforbox_brush[MAX_BRUSHFORBOX];