Sketcher: Ensure loop can exit

Coverity issue 513796
This commit is contained in:
Chris Hennes
2025-03-20 22:54:54 -05:00
committed by Benjamin Nauck
parent 5502fafafb
commit e12deea20e

View File

@@ -1044,6 +1044,14 @@ void CmdSketcherMergeSketches::activated(int iMsg)
int addedConstraints = mergesketch->addCopyOfConstraints(*Obj);
// Coverity issue 513796: make sure the loop below can complete
if (addedConstraints < 0) {
continue; // There were no constraints
}
if (addedConstraints - baseConstraints < 0) {
throw Base::ValueError("Constraint error in CmdSketcherMergeSketches");
}
for (int i = 0; i <= (addedConstraints - baseConstraints); i++) {
Sketcher::Constraint* constraint =
mergesketch->Constraints.getValues()[i + baseConstraints];