From 6136ec6347a5858a85912a805ea41126863558cd Mon Sep 17 00:00:00 2001 From: tsepez Date: Tue, 22 Nov 2016 13:01:40 -0800 Subject: Ensure CPDF_CountedObjects only made from owned references. Deletion of said object is still inflicted on the callers. But that's an issue for another day. Review-Url: https://codereview.chromium.org/2523743004 --- core/fpdfapi/page/cpdf_countedobject.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/page/cpdf_countedobject.h') diff --git a/core/fpdfapi/page/cpdf_countedobject.h b/core/fpdfapi/page/cpdf_countedobject.h index 97d710cf76..64f936c52c 100644 --- a/core/fpdfapi/page/cpdf_countedobject.h +++ b/core/fpdfapi/page/cpdf_countedobject.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_ #define CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_ +#include + #include "core/fpdfapi/page/cpdf_colorspace.h" #include "core/fpdfapi/page/cpdf_pattern.h" #include "core/fxcrt/fx_system.h" @@ -14,10 +16,11 @@ template class CPDF_CountedObject { public: - explicit CPDF_CountedObject(T* ptr) : m_nCount(1), m_pObj(ptr) {} - void reset(T* ptr) { // CAUTION: tosses prior ref counts. + explicit CPDF_CountedObject(std::unique_ptr ptr) + : m_nCount(1), m_pObj(ptr.release()) {} + void reset(std::unique_ptr ptr) { // CAUTION: tosses prior ref counts. m_nCount = 1; - m_pObj = ptr; + m_pObj = ptr.release(); } void clear() { // Now you're all weak ptrs ... // Guard against accidental re-entry. -- cgit v1.2.3