diff options
author | thestig <thestig@chromium.org> | 2016-01-04 14:25:34 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-04 22:26:41 +0000 |
commit | c2ebf3d0092b8bf990b9be0ac1a4cf547503d934 (patch) | |
tree | e41b22e7f2a0c20492e6f14e7a2ac850a65f711a | |
parent | 81a34db5d38e52941eedafdc2762f408fccba410 (diff) | |
download | chromium_src-c2ebf3d0092b8bf990b9be0ac1a4cf547503d934.zip chromium_src-c2ebf3d0092b8bf990b9be0ac1a4cf547503d934.tar.gz chromium_src-c2ebf3d0092b8bf990b9be0ac1a4cf547503d934.tar.bz2 |
PDF: Fix another case of circular references with bookmarks.
BUG=512790
Review URL: https://codereview.chromium.org/1559703002
Cr-Commit-Position: refs/heads/master@{#367386}
-rw-r--r-- | pdf/pdfium/pdfium_engine.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index ccee61a..f9e47f5 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -8,6 +8,8 @@ #include <stddef.h> #include <stdint.h> +#include <set> + #include "base/i18n/icu_encoding_detection.h" #include "base/i18n/icu_string_conversions.h" #include "base/json/json_writer.h" @@ -433,10 +435,15 @@ pp::VarDictionary TraverseBookmarks(FPDF_DOCUMENT doc, const unsigned int kMaxDepth = 128; if (depth < kMaxDepth) { int child_index = 0; + std::set<FPDF_BOOKMARK> seen_bookmarks; for (FPDF_BOOKMARK child_bookmark = FPDFBookmark_GetFirstChild(doc, bookmark); - child_bookmark != NULL; + child_bookmark; child_bookmark = FPDFBookmark_GetNextSibling(doc, child_bookmark)) { + if (ContainsKey(seen_bookmarks, child_bookmark)) + break; + + seen_bookmarks.insert(child_bookmark); children.Set(child_index, TraverseBookmarks(doc, child_bookmark, depth + 1)); child_index++; |