Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: core/fpdfapi/parser/cpdf_document_unittest.cpp

Issue 2445753002: Fix root dictionary leak in cpdf_document_unittest (Closed)
Patch Set: Use name convention Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_document_unittest.cpp
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index 34661b18153e16bb648369dba6c623391a9cae87..799ecc694e7c3ee11060309f759266cb9eba453d 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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698