From 69676a0f9d2d5b288bda3d1c6dbad5a6ec26bfaa Mon Sep 17 00:00:00 2001 From: Eric Price Date: Wed, 25 Sep 2024 17:33:03 +0200 Subject: [PATCH] Measurement: Avoid null shapes to be returned in all code branches (Fix #16820) Returning a null shape would have triggered an exception in the bottom branch but not in the top one - which later leads to a segfault - solution - raise an exception. OOC doesn't like null shapes. --- src/Mod/Measure/App/Measurement.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Mod/Measure/App/Measurement.cpp b/src/Mod/Measure/App/Measurement.cpp index e47cc89ead..ff8c42edeb 100644 --- a/src/Mod/Measure/App/Measurement.cpp +++ b/src/Mod/Measure/App/Measurement.cpp @@ -292,7 +292,11 @@ TopoDS_Shape Measurement::getShape(App::DocumentObject* rootObj, const char* sub std::vector names = Base::Tools::splitSubName(subName); if (names.empty() || names.back() == "") { - return Part::Feature::getShape(rootObj); + TopoDS_Shape shape = Part::Feature::getShape(rootObj); + if (shape.IsNull()) { + throw Part::NullShapeException("null shape in measurement"); + } + return shape; } try {