Skip to content

Commit

Permalink
IntersectionMatrix: Ignore patterns longer than 9 characters
Browse files Browse the repository at this point in the history
Fixes #1084
  • Loading branch information
dbaston committed Jun 17, 2024
1 parent 7590379 commit 64c96ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/geom/IntersectionMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ IntersectionMatrix::set(Location row, Location col, int dimensionValue)
void
IntersectionMatrix::set(const string& dimensionSymbols)
{
auto limit = dimensionSymbols.length();
auto limit = std::min(dimensionSymbols.length(), static_cast<std::size_t>(9));

for(size_t i = 0; i < limit; i++) {
auto row = i / firstDim;
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/capi/GEOSRelatePatternMatchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>

namespace tut {
//
Expand Down Expand Up @@ -101,5 +102,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

0 comments on commit 64c96ba

Please sign in to comment.