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

Side by Side Diff: fpdfsdk/src/fpdfppo.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_parser.cpp ('k') | 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 "public/fpdf_ppo.h" 7 #include "public/fpdf_ppo.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 case PDFOBJ_REFERENCE: { 206 case PDFOBJ_REFERENCE: {
207 CPDF_Reference* pReference = pObj->AsReference(); 207 CPDF_Reference* pReference = pObj->AsReference();
208 FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference); 208 FX_DWORD newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference);
209 if (newobjnum == 0) 209 if (newobjnum == 0)
210 return FALSE; 210 return FALSE;
211 pReference->SetRef(pDoc, newobjnum); 211 pReference->SetRef(pDoc, newobjnum);
212 break; 212 break;
213 } 213 }
214 case PDFOBJ_DICTIONARY: { 214 case PDFOBJ_DICTIONARY: {
215 CPDF_Dictionary* pDict = pObj->AsDictionary(); 215 CPDF_Dictionary* pDict = pObj->AsDictionary();
216 for (const auto& it : *pDict) { 216 auto it = pDict->begin();
217 const CFX_ByteString& key = it.first; 217 while (it != pDict->end()) {
218 CPDF_Object* pNextObj = it.second; 218 const CFX_ByteString& key = it->first;
219 CPDF_Object* pNextObj = it->second;
220 ++it;
219 if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") || 221 if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") ||
220 !FXSYS_strcmp(key, "First")) { 222 !FXSYS_strcmp(key, "First")) {
221 continue; 223 continue;
222 } 224 }
223 if (pNextObj) { 225 if (pNextObj) {
224 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap)) 226 if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
225 pDict->RemoveAt(key); 227 pDict->RemoveAt(key);
226 } else { 228 } else {
227 return FALSE; 229 return FALSE;
228 } 230 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 if (!pSrcDict) 398 if (!pSrcDict)
397 return FALSE; 399 return FALSE;
398 400
399 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot(); 401 CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
400 if (!pDstDict) 402 if (!pDstDict)
401 return FALSE; 403 return FALSE;
402 404
403 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE)); 405 pDstDict->SetAt("ViewerPreferences", pSrcDict->Clone(TRUE));
404 return TRUE; 406 return TRUE;
405 } 407 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698