summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/include/cpdf_annot.h
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-09-01 14:39:41 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-01 14:39:41 -0700
commit7c5d090719a25f0c1b81fb6b46544b9394a7fdd2 (patch)
tree8c341dd8f815902f77c7b6a3a569b8d24944b2c2 /core/fpdfdoc/include/cpdf_annot.h
parent4bae296c1eee7a1ecae8bab3d59dd9430218f730 (diff)
downloadpdfium-chromium/2847.tar.xz
Fix leaks due to created popup annotationschromium/2847
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
Diffstat (limited to 'core/fpdfdoc/include/cpdf_annot.h')
-rw-r--r--core/fpdfdoc/include/cpdf_annot.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/fpdfdoc/include/cpdf_annot.h b/core/fpdfdoc/include/cpdf_annot.h
index 82b3d3ca31..eb9f02a717 100644
--- a/core/fpdfdoc/include/cpdf_annot.h
+++ b/core/fpdfdoc/include/cpdf_annot.h
@@ -72,7 +72,7 @@ class CPDF_Annot {
const CFX_ByteString& sSubtype);
static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype);
- CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument);
+ CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument, bool bToOwnDict);
~CPDF_Annot();
CPDF_Annot::Subtype GetSubtype() const;
@@ -101,7 +101,11 @@ class CPDF_Annot {
private:
void GenerateAPIfNeeded();
- CPDF_Dictionary* const m_pAnnotDict;
+ // For regular annotations, |m_pAnnotDict| is not owned. For
+ // our artificially created popup annotations, |m_pAnnotDict|
+ // is owned by this class.
+ bool m_bOwnedAnnotDict;
+ CPDF_Dictionary* m_pAnnotDict;
CPDF_Document* const m_pDocument;
CPDF_Annot::Subtype m_nSubtype;
std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap;