From d8a2a532f9db9d41a6c448cecfb930e7f1141193 Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Fri, 25 Oct 2024 15:32:44 +0200 Subject: [PATCH] solidtest: Fix segfault in setExteriorShell test For the pointer version, The `Polyhedralsurface` takes ownership of the shell. This fixes commit 481cce229ba36d2493d413cc1e0a061eb340d95c. --- test/unit/SFCGAL/SolidTest.cpp | 3 ++- test/unit/SFCGAL/capi/sfcgal_cTest.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/unit/SFCGAL/SolidTest.cpp b/test/unit/SFCGAL/SolidTest.cpp index a0dc14e3..34e5eefb 100644 --- a/test/unit/SFCGAL/SolidTest.cpp +++ b/test/unit/SFCGAL/SolidTest.cpp @@ -21,6 +21,7 @@ #include "SFCGAL/Kernel.h" #include "SFCGAL/Solid.h" +#include "SFCGAL/PolyhedralSurface.h" #include "SFCGAL/TriangulatedSurface.h" #include "SFCGAL/io/wkt.h" #include "SFCGAL/algorithm/covers.h" @@ -130,7 +131,7 @@ BOOST_AUTO_TEST_CASE(solidSetExteriorRingTest) BOOST_CHECK(!shell1->isEmpty()); BOOST_CHECK(solid->isEmpty()); - solid->setExteriorShell(shell1); + solid->setExteriorShell(dynamic_cast(shell1.get())->clone()); BOOST_CHECK_EQUAL(solid->numShells(), 1); BOOST_CHECK(!solid->isEmpty()); BOOST_CHECK(algorithm::covers3D(solid->exteriorShell(), *shell1)); diff --git a/test/unit/SFCGAL/capi/sfcgal_cTest.cpp b/test/unit/SFCGAL/capi/sfcgal_cTest.cpp index 5012a05b..13e6ad08 100644 --- a/test/unit/SFCGAL/capi/sfcgal_cTest.cpp +++ b/test/unit/SFCGAL/capi/sfcgal_cTest.cpp @@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(testSolidSetExteriorShell) std::unique_ptr shell1(io::readWkt(polyhedral1Str)); BOOST_CHECK(!shell1->isEmpty()); - sfcgal_solid_set_exterior_shell(solid.get(), shell1.get()); + sfcgal_solid_set_exterior_shell(solid.get(), sfcgal_geometry_clone(shell1.get())); // check BOOST_CHECK(!solid->isEmpty());