aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRefCnt.h
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-05-08 13:32:02 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-08 18:47:14 +0000
commitefb84e6734074defa325a27273c8c98903955f52 (patch)
tree95fe5486a7b63c12365bfb907458fab5f44ec1e0 /include/core/SkRefCnt.h
parente1f566f2fd52e57cc945c0c9a3d7c19b4945b7b0 (diff)
sk_sp: check for self-assignment
Change-Id: I02e6ab8945c79c14458b36bd13ce6f6e14979460 Reviewed-on: https://skia-review.googlesource.com/126683 Reviewed-by: Ben Wagner <bungeman@google.com> Auto-Submit: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'include/core/SkRefCnt.h')
-rw-r--r--include/core/SkRefCnt.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 5d070a2cc1..0c3b23a7d1 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -291,7 +291,9 @@ public:
* object.
*/
sk_sp<T>& operator=(const sk_sp<T>& that) {
- this->reset(SkSafeRef(that.get()));
+ if (this != &that) {
+ this->reset(SkSafeRef(that.get()));
+ }
return *this;
}
template <typename U, typename = skstd::enable_if_t<std::is_convertible<U*, T*>::value>>