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

Side by Side Diff: fpdfsdk/fsdk_mgr.cpp

Issue 2242213004: Fix a double free in CPDFSDK_PageView::IsValidAnnot(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 4 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_mgr.h" 7 #include "fpdfsdk/include/fsdk_mgr.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 #else // PDF_ENABLE_XFA 1026 #else // PDF_ENABLE_XFA
1027 return GetPageIndexForStaticPDF(); 1027 return GetPageIndexForStaticPDF();
1028 #endif // PDF_ENABLE_XFA 1028 #endif // PDF_ENABLE_XFA
1029 } 1029 }
1030 1030
1031 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { 1031 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
1032 if (!p) 1032 if (!p)
1033 return false; 1033 return false;
1034 1034
1035 const auto& annots = m_pAnnotList->All(); 1035 const auto& annots = m_pAnnotList->All();
1036 std::unique_ptr<const CPDF_Annot> annot(p); 1036 auto it = std::find_if(annots.begin(), annots.end(),
1037 return pdfium::ContainsValue(annots, annot); 1037 [p](const std::unique_ptr<CPDF_Annot>& annot) {
1038 return annot.get() == p;
1039 });
1040 return it != annots.end();
1038 } 1041 }
1039 1042
1040 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() { 1043 CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
1041 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot(); 1044 CPDFSDK_Annot* pFocusAnnot = m_pSDKDoc->GetFocusAnnot();
1042 if (!pFocusAnnot) 1045 if (!pFocusAnnot)
1043 return nullptr; 1046 return nullptr;
1044 1047
1045 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) { 1048 for (CPDFSDK_Annot* pAnnot : m_fxAnnotArray) {
1046 if (pAnnot == pFocusAnnot) 1049 if (pAnnot == pFocusAnnot)
1047 return pAnnot; 1050 return pAnnot;
1048 } 1051 }
1049 return nullptr; 1052 return nullptr;
1050 } 1053 }
1051 1054
1052 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { 1055 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
1053 #ifdef PDF_ENABLE_XFA 1056 #ifdef PDF_ENABLE_XFA
1054 CPDF_Page* pPage = m_page->GetPDFPage(); 1057 CPDF_Page* pPage = m_page->GetPDFPage();
1055 #else // PDF_ENABLE_XFA 1058 #else // PDF_ENABLE_XFA
1056 CPDF_Page* pPage = m_page; 1059 CPDF_Page* pPage = m_page;
1057 #endif // PDF_ENABLE_XFA 1060 #endif // PDF_ENABLE_XFA
1058 CPDF_Dictionary* pDict = pPage->m_pFormDict; 1061 CPDF_Dictionary* pDict = pPage->m_pFormDict;
1059 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 1062 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
1060 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; 1063 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
1061 } 1064 }
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