From cae57daaa0f7ed4c92e22c4e7ef30392393d1128 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Wed, 13 Jan 2016 18:32:12 -0800 Subject: Fix some iterator invalidation issues while traversing CPDF_Dictionary. Also fixes a potential issue in CPDF_Dictionary::ReplaceKey. R=thestig@chromium.org BUG=577030 Review URL: https://codereview.chromium.org/1582963003 . --- fpdfsdk/src/fpdfppo.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp index dac548131e..47b91015a9 100644 --- a/fpdfsdk/src/fpdfppo.cpp +++ b/fpdfsdk/src/fpdfppo.cpp @@ -213,9 +213,11 @@ FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj, } case PDFOBJ_DICTIONARY: { CPDF_Dictionary* pDict = pObj->AsDictionary(); - for (const auto& it : *pDict) { - const CFX_ByteString& key = it.first; - CPDF_Object* pNextObj = it.second; + auto it = pDict->begin(); + while (it != pDict->end()) { + const CFX_ByteString& key = it->first; + CPDF_Object* pNextObj = it->second; + ++it; if (!FXSYS_strcmp(key, "Parent") || !FXSYS_strcmp(key, "Prev") || !FXSYS_strcmp(key, "First")) { continue; -- cgit v1.2.3