From 28d67eba2e94086ccefed6bff6b00a0671e3076e Mon Sep 17 00:00:00 2001 From: Rajendra Pardeshi Date: Thu, 26 Dec 2019 23:38:24 +0530 Subject: [PATCH] Issue ID 0004230 : Fixing a crash in chamfer command. Putting a null check for the function return value [skip ci] --- src/Gui/Document.cpp | 3 ++- src/Mod/Sketcher/Gui/Command.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 3e95f5586b..e28f44242b 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -786,7 +786,8 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop && d->_editingObject && d->_editViewProviderParent && (Prop.isDerivedFrom(App::PropertyPlacement::getClassTypeId()) - || strstr(Prop.getName(),"Scale")) + // Issue ID 0004230 : getName() can return null in which case strstr() crashes + || (Prop.getName() && strstr(Prop.getName(),"Scale"))) && d->_editObjs.count(&Obj)) { Base::Matrix4D mat; diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index abb32ef58e..85202e480e 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -723,8 +723,9 @@ void CmdSketcherMirrorSketch::activated(int iMsg) std::vector tempgeo = tempsketch->getInternalGeometry(); std::vector tempconstr = tempsketch->Constraints.getValues(); - std::vector mirrorgeo (tempgeo.begin()+addedGeometries+1,tempgeo.end()); - std::vector mirrorconstr (tempconstr.begin()+addedConstraints+1,tempconstr.end()); + // If value of addedGeometries or addedConstraints is -1, it gets added to vector begin iterator and that is invlid + std::vector mirrorgeo(tempgeo.begin() + (addedGeometries + 1), tempgeo.end()); + std::vector mirrorconstr(tempconstr.begin() + (addedConstraints + 1), tempconstr.end()); for (std::vector::const_iterator itc=mirrorconstr.begin(); itc != mirrorconstr.end(); ++itc) {