]> granicus.if.org Git - postgis/commitdiff
Guard GEOS from NaN and InF values in coordinates. (#627)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 8 Dec 2011 22:22:02 +0000 (22:22 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 8 Dec 2011 22:22:02 +0000 (22:22 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/1.4@8330 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos.c

index 1b9dcf1fb5217e3eabefc078ce8e51c23c777202..35aabe1bfc2f3207afc6d6511eddc85c326a18c5 100644 (file)
@@ -2660,6 +2660,15 @@ ptarray_to_GEOSCoordSeq(POINTARRAY *pa)
 
                POSTGIS_DEBUGF(4, "Point: %g,%g,%g", p.x, p.y, p.z);
 
+#if POSTGIS_GEOS_VERSION < 33
+               /* Make sure we don't pass any infinite values down into GEOS */
+               /* GEOS 3.3+ is supposed to  handle this stuff OK */
+               if ( isinf(p.x) || isinf(p.y) || (dims == 3 && isinf(p.z)) )
+                       lwerror("Infinite coordinate value found in geometry.");
+               if ( isnan(p.x) || isnan(p.y) || (dims == 3 && isnan(p.z)) )
+                       lwerror("NaN coordinate value found in geometry.");
+#endif
+
                GEOSCoordSeq_setX(sq, i, p.x);
                GEOSCoordSeq_setY(sq, i, p.y);
                if ( dims == 3 ) GEOSCoordSeq_setZ(sq, i, p.z);