PD: AddressSanitizer: heap-use-after-free

Fix crash inside TaskDlgSketchBasedParameters::reject()
This commit is contained in:
wmayer
2021-03-03 15:53:12 +01:00
parent 036c6b0d25
commit 0f3e98588f

View File

@@ -263,6 +263,7 @@ bool TaskDlgSketchBasedParameters::accept() {
bool TaskDlgSketchBasedParameters::reject()
{
PartDesign::ProfileBased* pcSketchBased = static_cast<PartDesign::ProfileBased*>(vp->getObject());
App::DocumentObjectWeakPtrT weakptr(pcSketchBased);
// get the Sketch
Sketcher::SketchObject *pcSketch = static_cast<Sketcher::SketchObject*>(pcSketchBased->Profile.getValue());
bool rv;
@@ -272,7 +273,7 @@ bool TaskDlgSketchBasedParameters::reject()
// if abort command deleted the object the sketch is visible again.
// The previous one feature already should be made visible
if (!Gui::Application::Instance->getViewProvider(pcSketchBased)) {
if (weakptr.expired()) {
// Make the sketch visible
if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch))
Gui::Application::Instance->getViewProvider(pcSketch)->show();