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

Raul raul at rmr.ninja
Wed Nov 21 06:11:16 PST 2018


Author: algunenano
Date: 2018-11-21 06:11:15 -0800 (Wed, 21 Nov 2018)
New Revision: 17041

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

References #4249



Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2018-11-21 14:10:31 UTC (rev 17040)
+++ branches/2.4/NEWS	2018-11-21 14:11:15 UTC (rev 17041)
@@ -19,6 +19,7 @@
   - #4326, Allocate enough memory in gidx_to_string (Raúl Marín)
   - #4190, Avoid undefined behaviour in gserialized_estimate (Raúl Marín)
   - #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.4.5

Modified: branches/2.4/raster/rt_core/rt_spatial_relationship.c
===================================================================
--- branches/2.4/raster/rt_core/rt_spatial_relationship.c	2018-11-21 14:10:31 UTC (rev 17040)
+++ branches/2.4/raster/rt_core/rt_spatial_relationship.c	2018-11-21 14:11:15 UTC (rev 17041)
@@ -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