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

Raul raul at rmr.ninja
Wed Nov 21 06:09:54 PST 2018


Author: algunenano
Date: 2018-11-21 06:09:53 -0800 (Wed, 21 Nov 2018)
New Revision: 17039

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

References #4249


Modified: branches/2.2/NEWS
===================================================================
--- branches/2.2/NEWS	2018-11-21 11:46:43 UTC (rev 17038)
+++ branches/2.2/NEWS	2018-11-21 14:09:53 UTC (rev 17039)
@@ -11,6 +11,7 @@
    - #4206, Fix support for PostgreSQL 12 dev branch (Laurenz Albe)
    - #3457, Fix raster envelope shortcut in ST_Clip (Sai-bot)
    - #4326, Allocate enough memory in gidx_to_string (Raúl Marín)
+   - #4249, Fix undefined behaviour in raster intersection (Raúl Marín)
 
 
 PostGIS 2.2.7

Modified: branches/2.2/raster/rt_core/rt_spatial_relationship.c
===================================================================
--- branches/2.2/raster/rt_core/rt_spatial_relationship.c	2018-11-21 11:46:43 UTC (rev 17038)
+++ branches/2.2/raster/rt_core/rt_spatial_relationship.c	2018-11-21 14:09:53 UTC (rev 17039)
@@ -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