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

Side by Side Diff: fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp

Issue 1667643002: Fix a crashier in CPDFSDK_Document::GetPageView() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/include/fsdk_define.h" 7 #include "fpdfsdk/include/fsdk_define.h"
8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" 8 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h"
9 #include "fpdfsdk/include/fsdk_mgr.h" 9 #include "fpdfsdk/include/fsdk_mgr.h"
10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" 10 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
(...skipping 27 matching lines...) Expand all
38 : m_iDocType(DOCTYPE_PDF), 38 : m_iDocType(DOCTYPE_PDF),
39 m_pPDFDoc(pPDFDoc), 39 m_pPDFDoc(pPDFDoc),
40 m_pSDKDoc(nullptr), 40 m_pSDKDoc(nullptr),
41 m_pXFADoc(nullptr), 41 m_pXFADoc(nullptr),
42 m_pXFADocView(nullptr), 42 m_pXFADocView(nullptr),
43 m_pApp(pProvider), 43 m_pApp(pProvider),
44 m_pJSContext(nullptr) { 44 m_pJSContext(nullptr) {
45 } 45 }
46 46
47 CPDFXFA_Document::~CPDFXFA_Document() { 47 CPDFXFA_Document::~CPDFXFA_Document() {
48 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv())
49 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
50
51 delete m_pSDKDoc;
52
53 if (m_pPDFDoc) {
54 CPDF_Parser* pParser = m_pPDFDoc->GetParser();
55 if (pParser)
56 delete pParser;
57 else
58 delete m_pPDFDoc;
59 }
60 if (m_pXFADoc) { 48 if (m_pXFADoc) {
61 IXFA_App* pApp = m_pApp->GetXFAApp(); 49 IXFA_App* pApp = m_pApp->GetXFAApp();
62 if (pApp) { 50 if (pApp) {
63 IXFA_DocHandler* pDocHandler = pApp->GetDocHandler(); 51 IXFA_DocHandler* pDocHandler = pApp->GetDocHandler();
64 if (pDocHandler) { 52 if (pDocHandler) {
65 CloseXFADoc(pDocHandler); 53 CloseXFADoc(pDocHandler);
66 } 54 }
67 } 55 }
68 delete m_pXFADoc; 56 delete m_pXFADoc;
69 } 57 }
58 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv())
59 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
60 delete m_pSDKDoc;
61 if (m_pPDFDoc) {
62 CPDF_Parser* pParser = m_pPDFDoc->GetParser();
63 if (pParser)
64 delete pParser;
65 else
66 delete m_pPDFDoc;
67 }
70 } 68 }
71 69
72 FX_BOOL CPDFXFA_Document::LoadXFADoc() { 70 FX_BOOL CPDFXFA_Document::LoadXFADoc() {
73 if (!m_pPDFDoc) 71 if (!m_pPDFDoc)
74 return FALSE; 72 return FALSE;
75 73
76 m_XFAPageList.RemoveAll(); 74 m_XFAPageList.RemoveAll();
77 75
78 IXFA_App* pApp = m_pApp->GetXFAApp(); 76 IXFA_App* pApp = m_pApp->GetXFAApp();
79 if (!pApp) 77 if (!pApp)
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 pPage = GetPage(nPageIndex); 481 pPage = GetPage(nPageIndex);
484 if (pPage) 482 if (pPage)
485 pPage->SetXFAPageView(pPageView); 483 pPage->SetXFAPageView(pPageView);
486 pEnv->FFI_PageEvent(nPageIndex, dwFlags); 484 pEnv->FFI_PageEvent(nPageIndex, dwFlags);
487 return; 485 return;
488 } 486 }
489 pPage = GetPage(pPageView); 487 pPage = GetPage(pPageView);
490 if (!pPage) 488 if (!pPage)
491 return; 489 return;
492 pEnv->FFI_PageEvent(pPage->GetPageIndex(), dwFlags); 490 pEnv->FFI_PageEvent(pPage->GetPageIndex(), dwFlags);
493 m_pSDKDoc->GetPageView(pPage)->ClearFXAnnots();
jun_fang 2016/02/04 06:15:10 When a XFA page is deleted, it doesn't need to cle
494 pPage->Release(); 491 pPage->Release();
495 } 492 }
496 493
497 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget, 494 void CPDFXFA_Document::WidgetEvent(IXFA_Widget* hWidget,
498 CXFA_WidgetAcc* pWidgetData, 495 CXFA_WidgetAcc* pWidgetData,
499 FX_DWORD dwEvent, 496 FX_DWORD dwEvent,
500 void* pParam, 497 void* pParam,
501 void* pAdditional) { 498 void* pAdditional) {
502 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) 499 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
503 return; 500 return;
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 } 1249 }
1253 1250
1254 return _GetHValueByName(szPropName, hValue, 1251 return _GetHValueByName(szPropName, hValue,
1255 m_pSDKDoc->GetEnv()->GetJSRuntime()); 1252 m_pSDKDoc->GetEnv()->GetJSRuntime());
1256 } 1253 }
1257 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, 1254 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name,
1258 FXJSE_HVALUE hValue, 1255 FXJSE_HVALUE hValue,
1259 IJS_Runtime* runTime) { 1256 IJS_Runtime* runTime) {
1260 return runTime->GetHValueByName(utf8Name, hValue); 1257 return runTime->GetHValueByName(utf8Name, hValue);
1261 } 1258 }
OLDNEW
« 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