| Index: pdf/pdfium/pdfium_engine.cc
|
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
|
| index 6506d8c96b1038af85ffed479c6b7d05e9dcb8c1..d5325c1ac4aca632eb679d14dd44e42b45e59fd6 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++;
|
|
|