summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2015-03-13 10:33:27 -0400
committerSteve Huston <shuston@riverace.com>2015-03-13 10:33:27 -0400
commit135bac34b594c10a2a058e4ad9d799e8e918bc47 (patch)
tree7efe86db7de1a089e0626ba4d74b790469bf92ba
parentbfce463fcd2e0e30c4eab6434594efa938ee2d80 (diff)
downloadATCD-135bac34b594c10a2a058e4ad9d799e8e918bc47.tar.gz
Add sanity check and test for new operator=
-rw-r--r--ACE/ace/INET_Addr.cpp3
-rw-r--r--ACE/tests/INET_Addr_Test.cpp9
2 files changed, 11 insertions, 1 deletions
diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp
index 96e26b93dcf..f12f3f83ada 100644
--- a/ACE/ace/INET_Addr.cpp
+++ b/ACE/ace/INET_Addr.cpp
@@ -182,7 +182,8 @@ ACE_INET_Addr::ACE_INET_Addr (void)
ACE_INET_Addr &
ACE_INET_Addr::operator= (const ACE_INET_Addr& rhs)
{
- this->set (rhs);
+ if (this != &rhs)
+ this->set (rhs);
return *this;
}
diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp
index 9e2cfc7a4a9..f216789a5bc 100644
--- a/ACE/tests/INET_Addr_Test.cpp
+++ b/ACE/tests/INET_Addr_Test.cpp
@@ -322,6 +322,15 @@ int run_main (int, ACE_TCHAR *[])
if (!test_multiple ())
status = 1;
+ ACE_INET_Addr a1 (80, "127.0.0.1");
+ ACE_INET_Addr a2 = a1;
+ if (a1 != a2)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Address equality check failed after assignment\n")));
+ status = 1;
+ }
+
ACE_END_TEST;
return status;