From 80f25a5a8135933a405349ffc798d13273b3d690 Mon Sep 17 00:00:00 2001 From: thestig Date: Thu, 19 May 2016 14:36:00 -0700 Subject: Fix leak in CPDF_StreamContentParser::AddTextObject(). ... by using STL containers in more places. Remove dead / duplicate code as well. BUG=603904 Review-Url: https://codereview.chromium.org/1998583002 --- core/fxcrt/include/fx_basic.h | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) (limited to 'core/fxcrt') diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h index 1835d9e0a6..7fdfbf699d 100644 --- a/core/fxcrt/include/fx_basic.h +++ b/core/fxcrt/include/fx_basic.h @@ -717,53 +717,22 @@ class CFX_CountRef { } } - ~CFX_CountRef() { - if (!m_pObject) { - return; - } - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - } + ~CFX_CountRef() { SetNull(); } ObjClass* New() { - if (m_pObject) { - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - } + SetNull(); m_pObject = new CountedObj; m_pObject->m_RefCount = 1; return m_pObject; } void operator=(const Ref& ref) { - if (ref.m_pObject) { + if (ref.m_pObject) ref.m_pObject->m_RefCount++; - } - if (m_pObject) { - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - } + SetNull(); m_pObject = ref.m_pObject; } - void operator=(void* p) { - ASSERT(p == 0); - if (!m_pObject) { - return; - } - m_pObject->m_RefCount--; - if (m_pObject->m_RefCount <= 0) { - delete m_pObject; - } - m_pObject = NULL; - } - const ObjClass* GetObject() const { return m_pObject; } operator const ObjClass*() const { return m_pObject; } -- cgit v1.2.3