diff --git a/include/boost/function.hpp b/include/boost/function.hpp index cd63901..4bacd2f 100644 --- a/include/boost/function.hpp +++ b/include/boost/function.hpp @@ -462,6 +462,9 @@ namespace boost { function& operator=(const function& f) { + if (this == &f) + return *this; + const base_type& bf = static_cast(f); base_type* self = this; self->set(bf); @@ -470,6 +473,9 @@ namespace boost { void set(const function& f) { + if (this == &f) + return; + const base_type& bf = static_cast(f); base_type* self = this; self->set(bf); diff --git a/include/boost/function/function_template.hpp b/include/boost/function/function_template.hpp index b8532de..8e70487 100644 --- a/include/boost/function/function_template.hpp +++ b/include/boost/function/function_template.hpp @@ -1044,6 +1044,9 @@ namespace boost { // Assignment from another BOOST_FUNCTION_FUNCTION BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f) { + if (this == &f) + return *this; + clear(); if (!f.empty()) { @@ -1064,6 +1067,9 @@ namespace boost { // Assignment from another BOOST_FUNCTION_FUNCTION void set(const BOOST_FUNCTION_FUNCTION& f) { + if (this == &f) + return; + clear(); if (!f.empty()) { @@ -1624,6 +1630,9 @@ namespace boost { // Assignment from another BOOST_FUNCTION_FUNCTION BOOST_FUNCTION_FUNCTION& operator=(const BOOST_FUNCTION_FUNCTION& f) { + if (this == &f) + return *this; + clear(); if (!f.empty()) { @@ -1644,6 +1653,9 @@ namespace boost { // Assignment from another BOOST_FUNCTION_FUNCTION void set(const BOOST_FUNCTION_FUNCTION& f) { + if (this == &f) + return; + clear(); if (!f.empty()) {