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

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_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: fix a bug in CPDF_Dictionary::ReplaceKey while we're at it 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
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/src/fpdfapi/fpdf_page/pageint.h" 7 #include "core/src/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include "core/include/fpdfapi/fpdf_module.h" 9 #include "core/include/fpdfapi/fpdf_module.h"
10 #include "core/include/fpdfapi/fpdf_page.h" 10 #include "core/include/fpdfapi/fpdf_page.h"
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 return; 489 return;
490 } 490 }
491 CFX_ByteString tag = GetString(0); 491 CFX_ByteString tag = GetString(0);
492 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE); 492 m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE);
493 } 493 }
494 494
495 void PDF_ReplaceAbbr(CPDF_Object* pObj) { 495 void PDF_ReplaceAbbr(CPDF_Object* pObj) {
496 switch (pObj->GetType()) { 496 switch (pObj->GetType()) {
497 case PDFOBJ_DICTIONARY: { 497 case PDFOBJ_DICTIONARY: {
498 CPDF_Dictionary* pDict = pObj->AsDictionary(); 498 CPDF_Dictionary* pDict = pObj->AsDictionary();
499 for (const auto& it : *pDict) { 499 auto it = pDict->begin();
500 CFX_ByteString key = it.first; 500 while (it != pDict->end()) {
501 CPDF_Object* value = it.second; 501 auto old_it = it++;
502 CFX_ByteString key = old_it->first;
503 CPDF_Object* value = old_it->second;
502 CFX_ByteStringC fullname = PDF_FindFullName( 504 CFX_ByteStringC fullname = PDF_FindFullName(
503 PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key); 505 PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
504 if (!fullname.IsEmpty()) { 506 if (!fullname.IsEmpty()) {
505 pDict->ReplaceKey(key, fullname); 507 pDict->ReplaceKey(key, fullname);
506 key = fullname; 508 key = fullname;
507 } 509 }
508 510
509 if (value->IsName()) { 511 if (value->IsName()) {
510 CFX_ByteString name = value->GetString(); 512 CFX_ByteString name = value->GetString();
511 fullname = PDF_FindFullName(PDF_InlineValueAbbr, 513 fullname = PDF_FindFullName(PDF_InlineValueAbbr,
(...skipping 24 matching lines...) Expand all
536 } 538 }
537 break; 539 break;
538 } 540 }
539 } 541 }
540 } 542 }
541 543
542 void PDF_ReplaceFull(CPDF_Object* pObj) { 544 void PDF_ReplaceFull(CPDF_Object* pObj) {
543 switch (pObj->GetType()) { 545 switch (pObj->GetType()) {
544 case PDFOBJ_DICTIONARY: { 546 case PDFOBJ_DICTIONARY: {
545 CPDF_Dictionary* pDict = pObj->AsDictionary(); 547 CPDF_Dictionary* pDict = pObj->AsDictionary();
546 for (const auto& it : *pDict) { 548 auto it = pDict->begin();
547 CFX_ByteString key = it.first; 549 while (it != pDict->end()) {
548 CPDF_Object* value = it.second; 550 auto old_it = it++;
551 CFX_ByteString key = old_it->first;
552 CPDF_Object* value = old_it->second;
549 CFX_ByteStringC abbrName = PDF_FindAbbrName( 553 CFX_ByteStringC abbrName = PDF_FindAbbrName(
550 PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key); 554 PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
551 if (!abbrName.IsEmpty()) { 555 if (!abbrName.IsEmpty()) {
552 pDict->ReplaceKey(key, abbrName); 556 pDict->ReplaceKey(key, abbrName);
553 key = abbrName; 557 key = abbrName;
554 } 558 }
555 if (value->IsName()) { 559 if (value->IsName()) {
556 CFX_ByteString name = value->GetString(); 560 CFX_ByteString name = value->GetString();
557 abbrName = PDF_FindAbbrName(PDF_InlineValueAbbr, 561 abbrName = PDF_FindAbbrName(PDF_InlineValueAbbr,
558 FX_ArraySize(PDF_InlineValueAbbr), name); 562 FX_ArraySize(PDF_InlineValueAbbr), name);
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 m_pObjectList->m_ObjectList.AddTail(pPathObj); 1520 m_pObjectList->m_ObjectList.AddTail(pPathObj);
1517 } 1521 }
1518 if (PathClipType) { 1522 if (PathClipType) {
1519 if (!matrix.IsIdentity()) { 1523 if (!matrix.IsIdentity()) {
1520 Path.Transform(&matrix); 1524 Path.Transform(&matrix);
1521 matrix.SetIdentity(); 1525 matrix.SetIdentity();
1522 } 1526 }
1523 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE); 1527 m_pCurStates->m_ClipPath.AppendPath(Path, PathClipType, TRUE);
1524 } 1528 }
1525 } 1529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698