diff options
author | Mark Dufour <m.dufour@kopano.com> | 2017-03-06 21:16:41 +0100 |
---|---|---|
committer | Mark Dufour <m.dufour@kopano.com> | 2017-03-06 21:16:41 +0100 |
commit | 5803e81d488e97623fe29b8629b977be01a8229e (patch) | |
tree | c7559f4d6b866fede791522fe579ab1368da6675 /Lib/python/pycontainer.swg | |
parent | e5add63548e7cbe980bf2a24b3064cf64876e280 (diff) | |
download | swig-5803e81d488e97623fe29b8629b977be01a8229e.tar.gz |
Fix Coverity issue reported for setslice (pycontainer.swg):
"CID 11151 (#3-1 of 3): Using invalid iterator (INVALIDATE_ITERATOR)18.
increment_iterator: Incrementing iterator it though it is already past
the end of its container."
Coverity does not understand 'replace_count', so warns that we may go
past self->end() (or self->rend() I guess).
Diffstat (limited to 'Lib/python/pycontainer.swg')
-rw-r--r-- | Lib/python/pycontainer.swg | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index d40b0baa8..9aefb4fc7 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -351,7 +351,7 @@ namespace swig { typename Sequence::const_iterator isit = is.begin(); typename Sequence::iterator it = self->begin(); std::advance(it,ii); - for (size_t rc=0; rc<replacecount; ++rc) { + for (size_t rc=0; rc<replacecount && it != self->end(); ++rc) { *it++ = *isit++; for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c) it++; @@ -367,7 +367,7 @@ namespace swig { typename Sequence::const_iterator isit = is.begin(); typename Sequence::reverse_iterator it = self->rbegin(); std::advance(it,size-ii-1); - for (size_t rc=0; rc<replacecount; ++rc) { + for (size_t rc=0; rc<replacecount && it != self->rend(); ++rc) { *it++ = *isit++; for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c) it++; |