From 638b004e829f0ca84172120af4a0bca436460281 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 17 Sep 2018 23:52:37 +0000 Subject: Make fxcrt::Retainable non-copyable. Because copying ref-counts from one object to another is a bad idea and sure to leak. Change-Id: I5f2c0891d08c893eb1ac8fb8a5908d975295ae2e Reviewed-on: https://pdfium-review.googlesource.com/42670 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- core/fxcrt/retain_ptr.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h index e14b1ef5dc..02faff611d 100644 --- a/core/fxcrt/retain_ptr.h +++ b/core/fxcrt/retain_ptr.h @@ -86,6 +86,8 @@ class RetainPtr { // Trivial implementation - internal ref count with virtual destructor. class Retainable { public: + Retainable() = default; + bool HasOneRef() const { return m_nRefCount == 1; } protected: @@ -98,6 +100,9 @@ class Retainable { template friend class RetainPtr; + Retainable(const Retainable& that) = delete; + Retainable& operator=(const Retainable& that) = delete; + void Retain() { ++m_nRefCount; } void Release() { ASSERT(m_nRefCount > 0); -- cgit v1.2.3