Fix self assigment in GrResourceKey
authorbsalomon <bsalomon@google.com>
Fri, 23 Jan 2015 15:17:55 +0000 (07:17 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 23 Jan 2015 15:17:55 +0000 (07:17 -0800)
TBR=robertphillips@google.com

BUG=skia:3340

Review URL: https://codereview.chromium.org/866263007

include/gpu/GrResourceKey.h

index d500a65..15d7b43 100644 (file)
@@ -49,10 +49,12 @@ protected:
     }
 
     GrResourceKey& operator=(const GrResourceKey& that) {
-        size_t bytes = that.size();
-        SkASSERT(SkIsAlign4(bytes));
-        fKey.reset(SkToInt(bytes / sizeof(uint32_t)));
-        memcpy(fKey.get(), that.fKey.get(), bytes);
+        if (this != &that) {
+            size_t bytes = that.size();
+            SkASSERT(SkIsAlign4(bytes));
+            fKey.reset(SkToInt(bytes / sizeof(uint32_t)));
+            memcpy(fKey.get(), that.fKey.get(), bytes);
+        }
         return *this;
     }