[GRASS-SVN] r29609 - grass/branches/releasebranch_6_3/lib/driver
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jan 8 08:21:12 EST 2008
Author: neteler
Date: 2008-01-08 08:21:12 -0500 (Tue, 08 Jan 2008)
New Revision: 29609
Modified:
grass/branches/releasebranch_6_3/lib/driver/Polygon.c
Log:
Fix overflow in polygon filler (merge from HEAD)
Modified: grass/branches/releasebranch_6_3/lib/driver/Polygon.c
===================================================================
--- grass/branches/releasebranch_6_3/lib/driver/Polygon.c 2008-01-08 13:17:56 UTC (rev 29608)
+++ grass/branches/releasebranch_6_3/lib/driver/Polygon.c 2008-01-08 13:21:12 UTC (rev 29609)
@@ -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