Sketcher: add security checks to avoid possible undefined behaviour

This commit is contained in:
wmayer
2023-11-27 10:58:50 +01:00
parent 5a4a358f13
commit f6d0340abc

View File

@@ -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<SelIdPair>& 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<SelIdPair>& selSeq,
// check if the edge already has a Block constraint
const std::vector<Sketcher::Constraint*>& vals = Obj->Constraints.getValues();
if (selSeq.empty()) {
return;
}
if (checkConstraint(vals,
Sketcher::Block,
selSeq.front().GeoId,