[postgis-tickets] r16586 - Inconsistent results from qsort callback (yugr)

Paul Ramsey pramsey at cleverelephant.ca
Tue May 22 12:38:12 PDT 2018


Author: pramsey
Date: 2018-05-22 12:38:12 -0700 (Tue, 22 May 2018)
New Revision: 16586

Modified:
   branches/2.2/NEWS
   branches/2.2/liblwgeom/effectivearea.c
   branches/2.2/liblwgeom/measures.c
Log:
Inconsistent results from qsort callback (yugr)
Closes #4093



Modified: branches/2.2/NEWS
===================================================================
--- branches/2.2/NEWS	2018-05-22 19:37:27 UTC (rev 16585)
+++ branches/2.2/NEWS	2018-05-22 19:38:12 UTC (rev 16586)
@@ -9,6 +9,7 @@
   - #3978, Fix KNN when upgrading from 2.1 or older (Sandro Santilli)
   - #4017, lwgeom lexer memory corruption (Peter E)
   - #4055, ST_ClusterIntersecting dropping SRID (Daniel Baston)
+  - #4093, Inconsistent results from qsort callback (yugr)
 
 
 PostGIS 2.2.6

Modified: branches/2.2/liblwgeom/effectivearea.c
===================================================================
--- branches/2.2/liblwgeom/effectivearea.c	2018-05-22 19:37:27 UTC (rev 16585)
+++ branches/2.2/liblwgeom/effectivearea.c	2018-05-22 19:38:12 UTC (rev 16586)
@@ -98,7 +98,7 @@
 	if (v1==v2)
 		return (*(areanode**)a)-(*(areanode**)b);
 	else
-		return  (v1>v2 ) ? 1 : -1;
+		return  (v1 > v2) ? 1 : ((v1 < v2) ? -1 : 0);
 }
 
 

Modified: branches/2.2/liblwgeom/measures.c
===================================================================
--- branches/2.2/liblwgeom/measures.c	2018-05-22 19:37:27 UTC (rev 16585)
+++ branches/2.2/liblwgeom/measures.c	2018-05-22 19:38:12 UTC (rev 16586)
@@ -2046,7 +2046,8 @@
 {
 	LISTSTRUCT *ia = (LISTSTRUCT*)a;
 	LISTSTRUCT *ib = (LISTSTRUCT*)b;
-	return ( ia->themeasure>ib->themeasure ) ? 1 : -1;
+	return 
+		(ia->themeasure > ib->themeasure) ? 1 : ((ia->themeasure < ib->themeasure) ? -1 : 0);
 }
 
 /**



More information about the postgis-tickets mailing list