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

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


Author: pramsey
Date: 2018-05-22 12:36:23 -0700 (Tue, 22 May 2018)
New Revision: 16584

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



Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2018-05-22 19:35:21 UTC (rev 16583)
+++ branches/2.4/NEWS	2018-05-22 19:36:23 UTC (rev 16584)
@@ -12,6 +12,7 @@
   - #3980, delay freeing input until processing complete (lucasvr)
   - #4090, PG 11 support (Paul Ramsey, Raúl Marín)
   - #3997, fix bug in lwgeom_median and avoid division by zero (Raúl Marín)
+  - #4093, Inconsistent results from qsort callback (yugr)
 
 
 PostGIS 2.4.4

Modified: branches/2.4/liblwgeom/effectivearea.c
===================================================================
--- branches/2.4/liblwgeom/effectivearea.c	2018-05-22 19:35:21 UTC (rev 16583)
+++ branches/2.4/liblwgeom/effectivearea.c	2018-05-22 19:36:23 UTC (rev 16584)
@@ -112,7 +112,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.4/liblwgeom/measures.c
===================================================================
--- branches/2.4/liblwgeom/measures.c	2018-05-22 19:35:21 UTC (rev 16583)
+++ branches/2.4/liblwgeom/measures.c	2018-05-22 19:36:23 UTC (rev 16584)
@@ -2060,7 +2060,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