Date: Fri, 8 Aug 2014 21:27:33 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269740 - head/contrib/libc++/include Message-ID: <53e540c5.2ba5.21a63362@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Fri Aug 8 21:27:33 2014 New Revision: 269740 URL: http://svnweb.freebsd.org/changeset/base/269740 Log: 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 Modified: head/contrib/libc++/include/list Modified: head/contrib/libc++/include/list ============================================================================== --- head/contrib/libc++/include/list Fri Aug 8 21:09:22 2014 (r269739) +++ head/contrib/libc++/include/list Fri Aug 8 21:27:33 2014 (r269740) @@ -2046,6 +2046,8 @@ list<_Tp, _Alloc>::remove(const value_ty 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 __pre for (; __j != __e && __pred(*__j); ++__j) ; __i = erase(__i, __j); + if (__i != __e) + __i = _VSTD::next(__i); } else ++__i;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53e540c5.2ba5.21a63362>