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

Unified Diff: core/src/fpdfdoc/doc_form.cpp

Issue 1387703002: Fix NULL pointer dereference in CPDF_InterForm. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 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 | « core/include/fpdfdoc/fpdf_doc.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfdoc/doc_form.cpp
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 970b4b9f40fa4780979e230ec7529950093b2c7c..17f180844426253861f91a9316c2641fe7c3b0b0 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -233,21 +233,25 @@ CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) {
return pNode;
}
CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP)
- : CFX_PrivateData() {
- m_pDocument = pDocument;
- m_bGenerateAP = bGenerateAP;
- m_pFormNotify = NULL;
- m_bUpdated = FALSE;
- m_pFieldTree = new CFieldTree;
+ : CFX_PrivateData(),
+ m_pDocument(pDocument),
+ m_bGenerateAP(bGenerateAP),
+ m_pFormDict(nullptr),
+ m_pFieldTree(new CFieldTree),
+ m_pFormNotify(nullptr),
+ m_bUpdated(FALSE) {
CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
+ if (!pRoot)
+ return;
+
m_pFormDict = pRoot->GetDict("AcroForm");
- if (m_pFormDict == NULL) {
+ if (!m_pFormDict)
return;
- }
+
CPDF_Array* pFields = m_pFormDict->GetArray("Fields");
- if (pFields == NULL) {
+ if (!pFields)
return;
- }
+
int count = pFields->GetCount();
for (int i = 0; i < count; i++) {
LoadField(pFields->GetDict(i));
@@ -257,12 +261,10 @@ CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP)
CPDF_InterForm::~CPDF_InterForm() {
for (auto it : m_ControlMap)
delete it.second;
- if (m_pFieldTree) {
- int nCount = m_pFieldTree->m_Root.CountFields();
- for (int i = 0; i < nCount; ++i) {
- delete m_pFieldTree->m_Root.GetField(i);
- }
- delete m_pFieldTree;
+
+ int nCount = m_pFieldTree->m_Root.CountFields();
+ for (int i = 0; i < nCount; ++i) {
+ delete m_pFieldTree->m_Root.GetField(i);
}
}
« no previous file with comments | « core/include/fpdfdoc/fpdf_doc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698