From af11e35fcb150013d3198b02820355ab803d3daf Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 10 Jun 2016 12:44:26 +0100 Subject: [PATCH] Fixed invalidated iterator bug pick up by Coverity. --- src/osgSim/ElevationSlice.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/osgSim/ElevationSlice.cpp b/src/osgSim/ElevationSlice.cpp index 130482a38..bdc4f193a 100644 --- a/src/osgSim/ElevationSlice.cpp +++ b/src/osgSim/ElevationSlice.cpp @@ -456,7 +456,7 @@ struct LineConstructor for(SegmentSet::iterator itr = _segments.begin(); itr != _segments.end(); - ++itr) + ) // itr increment is done manually at end of loop { SegmentSet::iterator nextItr = itr; ++nextItr; @@ -1056,6 +1056,9 @@ struct LineConstructor classification = ((itr != _segments.end()) && (nextItr != _segments.end())) ? itr->compare(*nextItr) : Segment::UNCLASSIFIED; } + + // increment iterator it it's not already at end of container. + if (itr!=_segments.end()) ++itr; } }