From 30c24ae0bc891a3cc7e093b8229a89197e84dc39 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 17 Feb 2021 22:12:43 -0600 Subject: [PATCH] [PD] Fix isFeatureMovable() to check null status of property As reported by @donovaly, if you try to move a pipe that does not have an auxilliary spine, the code segfaults. This commit adds a check to ensure that not only does the property exist (which in this case it always does), but also that it does not contain a null. That is a valid value for the property to have, but cannot be itself interrogated for moveability by the isFeatureMovable recursive call. This fix is also applied to the other similar conditions in that function to ensure they never yield the same segmentation fault. Forums topic: https://forum.freecadweb.org/viewtopic.php?p=479388#p479388 --- src/Mod/PartDesign/Gui/Utils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 1bd6f96a3b..0d5eb835b6 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -450,19 +450,19 @@ bool isFeatureMovable(App::DocumentObject* const feat) if (auto prop = static_cast(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (!isFeatureMovable(static_cast(axis))) + if (axis && !isFeatureMovable(static_cast(axis))) return false; } if (auto prop = static_cast(prim->getPropertyByName("Spine"))) { - App::DocumentObject* axis = prop->getValue(); - if (!isFeatureMovable(static_cast(axis))) + App::DocumentObject* spine = prop->getValue(); + if (spine && !isFeatureMovable(static_cast(spine))) return false; } if (auto prop = static_cast(prim->getPropertyByName("AuxillerySpine"))) { - App::DocumentObject* axis = prop->getValue(); - if (!isFeatureMovable(static_cast(axis))) + App::DocumentObject* auxSpine = prop->getValue(); + if (auxSpine && !isFeatureMovable(static_cast(auxSpine))) return false; }