From 7c5d090719a25f0c1b81fb6b46544b9394a7fdd2 Mon Sep 17 00:00:00 2001 From: weili Date: Thu, 1 Sep 2016 14:39:41 -0700 Subject: Fix leaks due to created popup annotations When we create popup annotations, we also create the dictionary associated with it. For regular annotations, the dictionary associated with an annotation is not owned by annotation, and will be released separately. But our created dictionary is not associated with any other data structure, it would be leaked if not released by the associated annotation. Add a boolean to indicate the ownership to the dictionary, and release the owned dictionary during the destruction of an annotation. BUG=pdfium:242 Review-Url: https://codereview.chromium.org/2301613002 --- core/fpdfdoc/cpdf_annot.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core/fpdfdoc/cpdf_annot.cpp') diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 6525ff620c..942d334a2d 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -18,8 +18,11 @@ #include "core/fxge/include/cfx_pathdata.h" #include "core/fxge/include/cfx_renderdevice.h" -CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument) - : m_pAnnotDict(pDict), +CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, + CPDF_Document* pDocument, + bool bToOwnDict) + : m_bOwnedAnnotDict(bToOwnDict), + m_pAnnotDict(pDict), m_pDocument(pDocument), m_bOpenState(false), m_pPopupAnnot(nullptr) { @@ -28,6 +31,8 @@ CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument) } CPDF_Annot::~CPDF_Annot() { + if (m_bOwnedAnnotDict) + m_pAnnotDict->Release(); ClearCachedAP(); } -- cgit v1.2.3