aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRefCnt.h
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-06 13:54:00 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-06 13:54:00 -0800
commit941da9d66171bd8efd2f6c5e25ff90c8c69885c1 (patch)
treea8ab867b53ab24493a2010cdd71224afaceeb791 /include/core/SkRefCnt.h
parent992854d62e179a589aa7366e443246e3672c3248 (diff)
Fix behavior of sk_sp::reset(T*) and add unittest.
Previously, sk_sp::reset(T* t) did not release its own reference if its internal pointer was the same as 't'. This leaks a reference. Now always release the current reference when non-nullptr. Review URL: https://codereview.chromium.org/1767983002
Diffstat (limited to 'include/core/SkRefCnt.h')
-rw-r--r--include/core/SkRefCnt.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 9b05ad4969..d33117751e 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -338,10 +338,8 @@ public:
* No call to ref() will be made.
*/
void reset(T* ptr = nullptr) {
- if (fPtr != ptr) {
- SkSafeUnref(fPtr);
- fPtr = ptr;
- }
+ SkSafeUnref(fPtr);
+ fPtr = ptr;
}
/**