[geos-commits] [SCM] GEOS branch main updated. d5d89d025fcd877fc96b80cd6a325b572a1b16f3
git at osgeo.org
git at osgeo.org
Mon Jan 12 08:09:25 PST 2026
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, main has been updated
via d5d89d025fcd877fc96b80cd6a325b572a1b16f3 (commit)
from 3f3a3e911f259b6fe76e18e05abe03c062d89aeb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d5d89d025fcd877fc96b80cd6a325b572a1b16f3
Author: Daniel Baston <dbaston at gmail.com>
Date: Mon Jan 12 11:09:06 2026 -0500
Fix crash in ConvexHull::preSort (#1358)
* Add test for GH-1072
Resolves https://github.com/libgeos/geos/issues/1072
* ConvexHull: improve robustness of polarCompare
diff --git a/src/algorithm/ConvexHull.cpp b/src/algorithm/ConvexHull.cpp
index 7d8e34374..1ed617438 100644
--- a/src/algorithm/ConvexHull.cpp
+++ b/src/algorithm/ConvexHull.cpp
@@ -63,13 +63,21 @@ private:
polarCompare(const Coordinate* o, const Coordinate* p,
const Coordinate* q)
{
- int orient = Orientation::index(*o, *p, *q);
+ // To use this comparator in std::sort it must provide a stable ordering, such that
+ // if cmp(a, b) is true then cmp(b, a) is false. Unfortunately Orientation::index may
+ // not provide this guarantee when the inputs differ by many orders of magnitude. To
+ // guard against this, we normalize the order of P and Q before calling OrientationIndex
+ // and flip the result if the inputs were flipped.
+ const bool swap = geom::CoordinateLessThan()(p, q);
+
+ const int orient = swap ? Orientation::index(*o, *q, *p) : Orientation::index(*o, *p, *q);
if(orient == Orientation::COUNTERCLOCKWISE) {
- return 1;
+ return swap ? -1 : 1;
}
+
if(orient == Orientation::CLOCKWISE) {
- return -1;
+ return swap ? 1 : -1;
}
/**
@@ -102,7 +110,7 @@ public:
RadiallyLessThen(const Coordinate* c): origin(c) {}
bool
- operator()(const Coordinate* p1, const Coordinate* p2)
+ operator()(const Coordinate* p1, const Coordinate* p2) const
{
return (polarCompare(origin, p1, p2) == -1);
}
diff --git a/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp b/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp
index f535fce86..3634752e9 100644
--- a/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp
+++ b/tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp
@@ -129,5 +129,20 @@ void object::test<5>
ensure("curved geometry not supported", result_ == nullptr);
}
+template<>
+template<>
+void object::test<6>
+()
+{
+ set_test_name("https://github.com/libgeos/geos/issues/1072");
+
+ geom1_ = fromWKT("LINESTRING(7777777777777777770 7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777770 1, 1 7 1,-2 1 2)");
+ geom2_ = GEOSSingleSidedBuffer(geom1_, 1.0, 64, 1, 1.0, 1);
+ result_ = GEOSMinimumBoundingCircle(geom2_, NULL, NULL);
+
+ // no segfault
+}
+
+
} // namespace tut
-----------------------------------------------------------------------
Summary of changes:
src/algorithm/ConvexHull.cpp | 16 ++++++++++++----
tests/unit/capi/GEOSMinimumBoundingCircleTest.cpp | 15 +++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list