diff --git a/src/geom/IntersectionMatrix.cpp b/src/geom/IntersectionMatrix.cpp index 82acfcf4ef..f7ace8a9e7 100644 --- a/src/geom/IntersectionMatrix.cpp +++ b/src/geom/IntersectionMatrix.cpp @@ -144,7 +144,7 @@ IntersectionMatrix::set(Location row, Location col, int dimensionValue) void IntersectionMatrix::set(const std::string& dimensionSymbols) { - auto limit = dimensionSymbols.length(); + auto limit = std::min(dimensionSymbols.length(), static_cast(9)); for(std::size_t i = 0; i < limit; i++) { auto row = i / firstDim; diff --git a/tests/unit/capi/GEOSRelatePatternMatchTest.cpp b/tests/unit/capi/GEOSRelatePatternMatchTest.cpp index c5f34a40b9..b60ab1e188 100644 --- a/tests/unit/capi/GEOSRelatePatternMatchTest.cpp +++ b/tests/unit/capi/GEOSRelatePatternMatchTest.cpp @@ -78,5 +78,18 @@ void object::test<5> ensure_equals(ret, char(0)); } +// invalid DE-9IM argument +// https://github.com/libgeos/geos/issues/1084 +template<> +template<> +void object::test<6> +() +{ + const char* mat = "0000000000"; + ensure_equals(strlen(mat), 10u); // not a valid DE-9IM! + + GEOSRelatePatternMatch(mat, "111111111"); +} + } // namespace tut