summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-12-29 20:03:55 +0000
committerEric Fiselier <eric@efcs.ca>2016-12-29 20:03:55 +0000
commitd566c345265421dedfb19d0c5a9a431d95b49b14 (patch)
tree5bbb83664903eb974c6b7f0f4ccfe4e5a40d9b84 /libcxx/include
parent7cc6059058a20a0008ae84c5363bbb9d9e0d8631 (diff)
downloadbcm5719-llvm-d566c345265421dedfb19d0c5a9a431d95b49b14.tar.gz
bcm5719-llvm-d566c345265421dedfb19d0c5a9a431d95b49b14.zip
Fix PR31489 - std::function self-swap segfaults
llvm-svn: 290721
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__functional_038
-rw-r--r--libcxx/include/functional2
2 files changed, 10 insertions, 0 deletions
diff --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03
index f8b5d956605..a1cec8bcac9 100644
--- a/libcxx/include/__functional_03
+++ b/libcxx/include/__functional_03
@@ -642,6 +642,8 @@ template<class _Rp>
void
function<_Rp()>::swap(function& __f)
{
+ if (_VSTD::addressof(__f) == this)
+ return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -916,6 +918,8 @@ template<class _Rp, class _A0>
void
function<_Rp(_A0)>::swap(function& __f)
{
+ if (_VSTD::addressof(__f) == this)
+ return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -1190,6 +1194,8 @@ template<class _Rp, class _A0, class _A1>
void
function<_Rp(_A0, _A1)>::swap(function& __f)
{
+ if (_VSTD::addressof(__f) == this)
+ return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -1464,6 +1470,8 @@ template<class _Rp, class _A0, class _A1, class _A2>
void
function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
{
+ if (_VSTD::addressof(__f) == this)
+ return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 0c450f15d1e..eb8609f1469 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -1870,6 +1870,8 @@ template<class _Rp, class ..._ArgTypes>
void
function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
{
+ if (_VSTD::addressof(__f) == this)
+ return;
if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_)
{
typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
OpenPOWER on IntegriCloud