guard for self-assignment in reset()
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 27 Nov 2012 17:20:39 +0000 (17:20 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 27 Nov 2012 17:20:39 +0000 (17:20 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@6568 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkRefCnt.h

index 3a0f8be..2d183cd 100644 (file)
@@ -155,8 +155,10 @@ public:
     T* get() const { return fObj; }
 
     void reset(T* obj) {
-        SkSafeUnref(fObj);
-        fObj = obj;
+        if (obj != fObj) {
+            SkSafeUnref(fObj);
+            fObj = obj;
+        }
     }
 
     void swap(SkAutoTUnref* other) {