From f6d0340abcb68ea2181dadaa6ccdd2cbae30f5e5 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 27 Nov 2023 10:58:50 +0100 Subject: [PATCH] Sketcher: add security checks to avoid possible undefined behaviour --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index af668c9236..ceb14da285 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -2799,6 +2799,10 @@ void horVerApplyConstraint(CmdSketcherConstraint* cmd, std::string type, std::ve switch (seqIndex) { case 0:// {Edge} { + if (selSeq.empty()) { + return; + } + int CrvId = selSeq.front().GeoId; if (CrvId != -1) { const Part::Geometry* geo = Obj->getGeometry(CrvId); @@ -3240,6 +3244,10 @@ void CmdSketcherConstrainLock::applyConstraint(std::vector& selSeq, i // check if the edge already has a Block constraint bool pointfixed = false; + if (selSeq.empty()) { + return; + } + if (isPointOrSegmentFixed(Obj, selSeq.front().GeoId)) { pointfixed = true; } @@ -3452,6 +3460,10 @@ void CmdSketcherConstrainBlock::applyConstraint(std::vector& selSeq, // check if the edge already has a Block constraint const std::vector& vals = Obj->Constraints.getValues(); + if (selSeq.empty()) { + return; + } + if (checkConstraint(vals, Sketcher::Block, selSeq.front().GeoId,