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

Side by Side Diff: fpdfsdk/src/fpdfdoc_embeddertest.cpp

Issue 1757373002: Fix infinite loop for bookmark search (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fpdfdoc.cpp ('k') | testing/resources/bookmarks_circular.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/include/fxcrt/fx_string.h" 5 #include "core/include/fxcrt/fx_string.h"
6 #include "public/fpdf_doc.h" 6 #include "public/fpdf_doc.h"
7 #include "public/fpdfview.h" 7 #include "public/fpdfview.h"
8 #include "testing/embedder_test.h" 8 #include "testing/embedder_test.h"
9 #include "testing/fx_string_testhelpers.h" 9 #include "testing/fx_string_testhelpers.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 CFX_WideString::FromUTF16LE(buf, 16)); 118 CFX_WideString::FromUTF16LE(buf, 16));
119 119
120 // Check that it is them same as the one returned by GetFirstChild. 120 // Check that it is them same as the one returned by GetFirstChild.
121 EXPECT_EQ(child, FPDFBookmark_GetFirstChild(document(), nullptr)); 121 EXPECT_EQ(child, FPDFBookmark_GetFirstChild(document(), nullptr));
122 122
123 // Try to find one using a non-existent title. 123 // Try to find one using a non-existent title.
124 std::unique_ptr<unsigned short, pdfium::FreeDeleter> bad_title = 124 std::unique_ptr<unsigned short, pdfium::FreeDeleter> bad_title =
125 GetFPDFWideString(L"A BAD Beginning"); 125 GetFPDFWideString(L"A BAD Beginning");
126 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), bad_title.get())); 126 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), bad_title.get()));
127 } 127 }
128
129 // Check circular bookmarks will not cause infinite loop.
130 TEST_F(FPDFDocEmbeddertest, FindBookmarks_bug420) {
131 // Open a file with circular bookmarks.
132 EXPECT_TRUE(OpenDocument("bookmarks_circular.pdf"));
133
134 // Try to find a title.
135 std::unique_ptr<unsigned short, pdfium::FreeDeleter> title =
136 GetFPDFWideString(L"anything");
137 EXPECT_EQ(nullptr, FPDFBookmark_Find(document(), title.get()));
138 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfdoc.cpp ('k') | testing/resources/bookmarks_circular.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698