[postgis-tickets] r17042 - Fix undefined behaviour in raster intersection

Raul raul at rmr.ninja
Wed Nov 21 06:13:04 PST 2018


Author: algunenano
Date: 2018-11-21 06:13:03 -0800 (Wed, 21 Nov 2018)
New Revision: 17042

Modified:
   branches/2.5/NEWS
   branches/2.5/raster/rt_core/rt_spatial_relationship.c
Log:
Fix undefined behaviour in raster intersection

References #4249



Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2018-11-21 14:11:15 UTC (rev 17041)
+++ branches/2.5/NEWS	2018-11-21 14:13:03 UTC (rev 17042)
@@ -3,6 +3,7 @@
 
  * Bug fixes *
   - #4247, Avoid undefined behaviour in next_float functions (Raúl Marín)
+  - #4249, Fix undefined behaviour in raster intersection (Raúl Marín)
 
 PostGIS 2.5.1
 2018/11/18

Modified: branches/2.5/raster/rt_core/rt_spatial_relationship.c
===================================================================
--- branches/2.5/raster/rt_core/rt_spatial_relationship.c	2018-11-21 14:11:15 UTC (rev 17041)
+++ branches/2.5/raster/rt_core/rt_spatial_relationship.c	2018-11-21 14:13:03 UTC (rev 17042)
@@ -715,12 +715,10 @@
 		gt2
 	);
 
-	/* parallel vertically */
-	if (FLT_EQ(line1[X2] - line1[X1], 0.) && FLT_EQ(line2[X2] - line2[X1], 0.))
+	/* Parallel lines */
+	if (FLT_EQ(((line1[X2] - line1[X1]) * (line2[Y2] - line2[Y1])),
+		   ((line2[X2] - line2[X1]) * (line1[Y2] - line1[Y1]))))
 		byHeight = 0;
-	/* parallel */
-	else if (FLT_EQ(((line1[Y2] - line1[Y1]) / (line1[X2] - line1[X1])), ((line2[Y2] - line2[Y1]) / (line2[X2] - line2[X1]))))
-		byHeight = 0;
 
 	if (byHeight)
 		dimValue = height2;



More information about the postgis-tickets mailing list