diff options
author | arseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640> | 2012-11-08 16:01:23 +0000 |
---|---|---|
committer | arseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640> | 2012-11-08 16:01:23 +0000 |
commit | 43f3888dc14c81fa8f6b917c2a3acce342e09b2f (patch) | |
tree | 5ccc3a57ed2f99a56c689fe5cd64baa2fed9e1de /src | |
parent | 973296bcb155a59b143ed5848771e7c5fed74c4d (diff) |
Fix undefined pointer arithmetic for reverse() and unique() in case the range is empty (begin == end)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@926 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src')
-rw-r--r-- | src/pugixml.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 1422eb0..da6d447 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -5479,13 +5479,13 @@ PUGI__NS_BEGIN template <typename I> void reverse(I begin, I end) { - while (begin + 1 < end) swap(*begin++, *--end); + while (end - begin > 1) swap(*begin++, *--end); } template <typename I> I unique(I begin, I end) { // fast skip head - while (begin + 1 < end && *begin != *(begin + 1)) begin++; + while (end - begin > 1 && *begin != *(begin + 1)) begin++; if (begin == end) return begin; |