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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1582963003: Fix some iterator invalidation issues while traversing CPDF_Dictionary. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase, use Lei's fix Created 4 years, 11 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 | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | fpdfsdk/src/fpdfppo.cpp » ('j') | 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 "core/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } else { 878 } else {
879 CPDF_Stream* pStream = pObj->AsStream(); 879 CPDF_Stream* pStream = pObj->AsStream();
880 if (CPDF_Dictionary* pTrailer = 880 if (CPDF_Dictionary* pTrailer =
881 pStream ? pStream->GetDict() : pObj->AsDictionary()) { 881 pStream ? pStream->GetDict() : pObj->AsDictionary()) {
882 if (m_pTrailer) { 882 if (m_pTrailer) {
883 CPDF_Object* pRoot = pTrailer->GetElement("Root"); 883 CPDF_Object* pRoot = pTrailer->GetElement("Root");
884 CPDF_Reference* pRef = ToReference(pRoot); 884 CPDF_Reference* pRef = ToReference(pRoot);
885 if (!pRoot || 885 if (!pRoot ||
886 (pRef && IsValidObjectNumber(pRef->GetRefObjNum()) && 886 (pRef && IsValidObjectNumber(pRef->GetRefObjNum()) &&
887 m_ObjectInfo[pRef->GetRefObjNum()].pos != 0)) { 887 m_ObjectInfo[pRef->GetRefObjNum()].pos != 0)) {
888 for (const auto& it : *pTrailer) { 888 auto it = pTrailer->begin();
889 const CFX_ByteString& key = it.first; 889 while (it != pTrailer->end()) {
890 CPDF_Object* pElement = it.second; 890 const CFX_ByteString& key = it->first;
891 CPDF_Object* pElement = it->second;
892 ++it;
891 FX_DWORD dwObjNum = 893 FX_DWORD dwObjNum =
892 pElement ? pElement->GetObjNum() : 0; 894 pElement ? pElement->GetObjNum() : 0;
893 if (dwObjNum) { 895 if (dwObjNum) {
894 m_pTrailer->SetAtReference(key, m_pDocument, 896 m_pTrailer->SetAtReference(key, m_pDocument,
895 dwObjNum); 897 dwObjNum);
896 } else { 898 } else {
897 m_pTrailer->SetAt(key, pElement->Clone()); 899 m_pTrailer->SetAt(key, pElement->Clone());
898 } 900 }
899 } 901 }
900 pObj->Release(); 902 pObj->Release();
(...skipping 4105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5006 if (!m_pLinearizedDict) 5008 if (!m_pLinearizedDict)
5007 return -1; 5009 return -1;
5008 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 5010 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H");
5009 if (!pRange) 5011 if (!pRange)
5010 return -1; 5012 return -1;
5011 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 5013 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
5012 if (!pStreamLen) 5014 if (!pStreamLen)
5013 return -1; 5015 return -1;
5014 return pStreamLen->GetInteger(); 5016 return pStreamLen->GetInteger();
5015 } 5017 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp ('k') | fpdfsdk/src/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698