From 54c278c1235435f1c5898334b98b103225827bd7 Mon Sep 17 00:00:00 2001 From: Eric Price Date: Wed, 25 Sep 2024 00:37:58 +0200 Subject: [PATCH] Measurement: Correctly handle unknown selections to avoid segfaults (Fix 16794) The measurement code did not handle mixed selections of known and unknown types correctly. Although a unknown selected object would leave the type at Invalid, selecting both known and unknown objects would have the type determined by the known object type and treat the unknown as the same. This causes exceptions and - worst case a segmentation fault. This fix introduces a new category "other" which - if present in a selection always forces type to Invalid. This should be forward compatible in case new types are introduced in the future. --- src/Mod/Measure/App/Measurement.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mod/Measure/App/Measurement.cpp b/src/Mod/Measure/App/Measurement.cpp index 2b195f77a4..e47cc89ead 100644 --- a/src/Mod/Measure/App/Measurement.cpp +++ b/src/Mod/Measure/App/Measurement.cpp @@ -123,6 +123,7 @@ MeasureType Measurement::findType() int torus = 0; int spheres = 0; int vols = 0; + int other = 0; for (; obj != objects.end(); ++obj, ++subEl) { @@ -184,12 +185,16 @@ MeasureType Measurement::findType() } } break; default: + other++; break; } } } - if (vols > 0) { + if (other > 0) { + mode = MeasureType::Invalid; + } + else if (vols > 0) { if (verts > 0 || edges > 0 || faces > 0) { mode = MeasureType::Invalid; }