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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 1559703002: PDF: Fix another case of circular references with bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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++;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698