summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2016-10-24 13:12:32 -0400
committerNicolas Pena <npm@chromium.org>2016-10-24 13:12:32 -0400
commitb674ebe6dd13288160ad8e324d719a124caf5a83 (patch)
tree180ec00a9e370a022d92e95d537d96c5f3435d00 /core
parent3cad596c55cd4db64e002aba118904f65c385168 (diff)
downloadpdfium-b674ebe6dd13288160ad8e324d719a124caf5a83.tar.xz
Fix root dictionary leak in cpdf_document_unittest
The CPDF_Document does not own its root dictionary, so add ownership in CPDF_TestDocumentForPages, using ReleaseDeleter because the dictionary cannot be deleted. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/2445753002 .
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index 34661b1815..799ecc694e 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
+#include "core/fxcrt/fx_memory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -68,11 +69,16 @@ class CPDF_TestDocumentForPages : public CPDF_Document {
allPages->AddReference(this, branch4->GetObjNum());
CPDF_Dictionary* pagesDict = CreatePageTreeNode(allPages, this, 7);
- CPDF_Dictionary* root = new CPDF_Dictionary();
- root->SetReferenceFor("Pages", this, AddIndirectObject(pagesDict));
- m_pRootDict = root;
+ m_pOwnedRootDict.reset(new CPDF_Dictionary());
+ m_pOwnedRootDict->SetReferenceFor("Pages", this,
+ AddIndirectObject(pagesDict));
+ m_pRootDict = m_pOwnedRootDict.get();
m_PageList.SetSize(7);
}
+
+ private:
+ std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>
+ m_pOwnedRootDict;
};
TEST(cpdf_document, GetPages) {