Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 6506d8c96b1038af85ffed479c6b7d05e9dcb8c1..dead98e535d006142ab7532790a3d93d18e810d5 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 != nullptr; |
|
Tom Sepez
2016/01/04 18:59:22
nit: just child_bookmark;
Lei Zhang
2016/01/04 21:44:43
Done.
|
| 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++; |