summaryrefslogtreecommitdiffstats
path: root/contrib/libc++
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-08-11 20:37:03 +0000
committerdim <dim@FreeBSD.org>2014-08-11 20:37:03 +0000
commitf8d542ba4ffd3be1835474a94d57f77b99f7d313 (patch)
tree5ce0ebf100c0f78c6719d251dc16438ab5e3e4b1 /contrib/libc++
parentc7338ae617791df4b69298de07e97949d2d3bf51 (diff)
downloadFreeBSD-src-f8d542ba4ffd3be1835474a94d57f77b99f7d313.zip
FreeBSD-src-f8d542ba4ffd3be1835474a94d57f77b99f7d313.tar.gz
MFC r269740:
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
Diffstat (limited to 'contrib/libc++')
-rw-r--r--contrib/libc++/include/list4
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/libc++/include/list b/contrib/libc++/include/list
index 800a1a3..7ccc778 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;
OpenPOWER on IntegriCloud