]> git.saurik.com Git - wxWidgets.git/commitdiff
check for self assignment in operator=
authorPaul Cornett <paulcor@bullseye.com>
Wed, 2 Dec 2009 16:36:50 +0000 (16:36 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Wed, 2 Dec 2009 16:36:50 +0000 (16:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/any.h
include/wx/osx/core/cfref.h
include/wx/private/sckaddr.h

index b99e84bb99ae987a5caf0d942eb5f576f69cde4c..26f36e7c68a7f6a8bab6b91fd9fa5dd39602475a 100644 (file)
@@ -663,7 +663,8 @@ public:
     */
     wxAny& operator=(const wxAny &any)
     {
     */
     wxAny& operator=(const wxAny &any)
     {
-        AssignAny(any);
+        if (this != &any)
+            AssignAny(any);
         return *this;
     }
 
         return *this;
     }
 
index eb6adeeee03f22f67c19ff473f611bc084a5ea47..cb4f6364986b02f800125a951d35a03f73a41e9c 100644 (file)
@@ -234,9 +234,12 @@ public:
     */
     wxCFRef& operator=(const wxCFRef& otherRef)
     {
     */
     wxCFRef& operator=(const wxCFRef& otherRef)
     {
-        wxCFRetain(otherRef.m_ptr);
-        wxCFRelease(m_ptr);
-        m_ptr = otherRef.m_ptr;
+        if (this != &otherRef)
+        {
+            wxCFRetain(otherRef.m_ptr);
+            wxCFRelease(m_ptr);
+            m_ptr = otherRef.m_ptr;
+        }
         return *this;
     }
 
         return *this;
     }
 
index 7babad5a8bf76c6c016b03a149f4ccb4fe59817d..a0e0ec4ee1f05901ee2b350e1562376f6e4fce96 100644 (file)
@@ -137,10 +137,11 @@ public:
 
     wxSockAddressImpl& operator=(const wxSockAddressImpl& other)
     {
 
     wxSockAddressImpl& operator=(const wxSockAddressImpl& other)
     {
-        free(m_addr);
-
-        InitFromOther(other);
-
+        if (this != &other)
+        {
+            free(m_addr);
+            InitFromOther(other);
+        }
         return *this;
     }
 
         return *this;
     }