From 4efd9d9872420b40f618294a0db4bbf7f70405d2 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Tue, 27 Nov 2012 17:20:39 +0000 Subject: guard for self-assignment in reset() git-svn-id: http://skia.googlecode.com/svn/trunk@6568 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkRefCnt.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/core') diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h index 3a0f8be383..2d183cd844 100644 --- a/include/core/SkRefCnt.h +++ b/include/core/SkRefCnt.h @@ -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) { -- cgit v1.2.3