72a884
From 5803e81d488e97623fe29b8629b977be01a8229e Mon Sep 17 00:00:00 2001
72a884
From: Mark Dufour <m.dufour@kopano.com>
72a884
Date: Mon, 6 Mar 2017 21:16:41 +0100
72a884
Subject: [PATCH] Fix Coverity issue reported for setslice (pycontainer.swg):
72a884
72a884
"CID 11151 (#3-1 of 3): Using invalid iterator (INVALIDATE_ITERATOR)18.
72a884
increment_iterator: Incrementing iterator it though it is already past
72a884
the end of its container."
72a884
72a884
Coverity does not understand 'replace_count', so warns that we may go
72a884
past self->end() (or self->rend() I guess).
72a884
---
72a884
 Lib/python/pycontainer.swg | 4 ++--
72a884
 1 file changed, 2 insertions(+), 2 deletions(-)
72a884
72a884
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
72a884
index d40b0baa8..9aefb4fc7 100644
72a884
--- a/Lib/python/pycontainer.swg
72a884
+++ b/Lib/python/pycontainer.swg
72a884
@@ -351,7 +351,7 @@ namespace swig {
72a884
         typename Sequence::const_iterator isit = is.begin();
72a884
         typename Sequence::iterator it = self->begin();
72a884
         std::advance(it,ii);
72a884
-        for (size_t rc=0; rc
72a884
+        for (size_t rc=0; rc<replacecount && it != self->end(); ++rc) {
72a884
           *it++ = *isit++;
72a884
           for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
72a884
             it++;
72a884
@@ -367,7 +367,7 @@ namespace swig {
72a884
       typename Sequence::const_iterator isit = is.begin();
72a884
       typename Sequence::reverse_iterator it = self->rbegin();
72a884
       std::advance(it,size-ii-1);
72a884
-      for (size_t rc=0; rc
72a884
+      for (size_t rc=0; rc<replacecount && it != self->rend(); ++rc) {
72a884
         *it++ = *isit++;
72a884
         for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
72a884
           it++;
72a884
-- 
72a884
2.14.3
72a884