diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2014-08-08 21:27:33 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2014-08-08 21:27:33 +0000 |
commit | f48026fc6988487b7428fe43413c6157a09c90d9 (patch) | |
tree | 04035b08e3575b23f3f7e23f31f4dccfc8afe461 /contrib/libc++ | |
parent | 6b6e7079b3ff3fbd7a5354a10a2c2d6d99831889 (diff) | |
download | src-f48026fc6988487b7428fe43413c6157a09c90d9.tar.gz src-f48026fc6988487b7428fe43413c6157a09c90d9.zip |
Pull in r214736 from upstream libc++ trunk (by Marshall Clow):
Fix PR#20520 - predicate called too many times in list::remove_if.
Add tests for list, forward_list, and the std::remove_if algorithm
This fixes an issue where std::list<>::remove_if() and remove() could
erroneously visit elements twice.
Reported by: Dominic Fandrey <kamikaze@bsdforen.de>
PR: 192303
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=269740
Diffstat (limited to 'contrib/libc++')
-rw-r--r-- | contrib/libc++/include/list | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/libc++/include/list b/contrib/libc++/include/list index 800a1a3f5aa8..7ccc778c9436 100644 --- a/contrib/libc++/include/list +++ b/contrib/libc++/include/list @@ -2046,6 +2046,8 @@ list<_Tp, _Alloc>::remove(const value_type& __x) for (; __j != __e && *__j == __x; ++__j) ; __i = erase(__i, __j); + if (__i != __e) + __i = _VSTD::next(__i); } else ++__i; @@ -2065,6 +2067,8 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred) for (; __j != __e && __pred(*__j); ++__j) ; __i = erase(__i, __j); + if (__i != __e) + __i = _VSTD::next(__i); } else ++__i; |