From e83dd3c0cefcff8dab8aa5cefc09876e1456d0e7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 19 Jul 2020 19:23:47 +0200 Subject: [PATCH] Coverity: Using invalid iterator --- src/Mod/Sketcher/App/SketchObject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c599f00160..5687ea1a12 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1220,6 +1220,8 @@ int SketchObject::delConstraint(int ConstrId) int SketchObject::delConstraints(std::vector ConstrIds, bool updategeometry) { Base::StateLocker lock(managedoperation, true); // no need to check input data validity as this is an sketchobject managed operation. + if (ConstrIds.empty()) + return 0; const std::vector< Constraint * > &vals = this->Constraints.getValues(); @@ -1227,7 +1229,7 @@ int SketchObject::delConstraints(std::vector ConstrIds, bool updategeometry std::sort(ConstrIds.begin(),ConstrIds.end()); - if (*ConstrIds.begin() < 0 || *std::prev(ConstrIds.end()) >= int(vals.size())) + if (ConstrIds.front() < 0 || ConstrIds.back() >= int(vals.size())) return -1; for(auto rit = ConstrIds.rbegin(); rit!=ConstrIds.rend(); rit++)