Skip to content

Commit

Permalink
Measurement: Avoid null shapes to be returned in all code branches (Fix
Browse files Browse the repository at this point in the history
FreeCAD#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.
  • Loading branch information
AIRCAP authored and chennes committed Sep 25, 2024
1 parent 9df2ec7 commit 69676a0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Mod/Measure/App/Measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ TopoDS_Shape Measurement::getShape(App::DocumentObject* rootObj, const char* sub
std::vector<std::string> 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 {
Expand Down

0 comments on commit 69676a0

Please sign in to comment.