[GRASS-SVN] r29488 - grass/trunk/lib/driver
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 20 19:57:40 EST 2007
Author: glynn
Date: 2007-12-20 19:57:40 -0500 (Thu, 20 Dec 2007)
New Revision: 29488
Modified:
grass/trunk/lib/driver/Polygon.c
Log:
Fix overflow in polygon filler
Modified: grass/trunk/lib/driver/Polygon.c
===================================================================
--- grass/trunk/lib/driver/Polygon.c 2007-12-20 22:31:06 UTC (rev 29487)
+++ grass/trunk/lib/driver/Polygon.c 2007-12-21 00:57:40 UTC (rev 29488)
@@ -33,6 +33,7 @@
const struct point *p0 = &p[i];
const struct point *p1 = &p[i + 1];
const struct point *tmp;
+ double fx;
long x;
if (p0->y == p1->y)
@@ -47,8 +48,11 @@
if (p1->y <= y)
continue;
- x = p1->x * (y - p0->y) + p0->x * (p1->y - y);
- x /= p1->y - p0->y;
+ fx = (double) p1->x * (y - p0->y) + (double) p0->x * (p1->y - y);
+ fx /= p1->y - p0->y;
+ x = fx < -0x7fffffff ? -0x7fffffff :
+ fx > 0x7fffffff ? 0x7fffffff :
+ (long) fx;
if (num_x >= max_x)
{
More information about the grass-commit
mailing list