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

Side by Side Diff: fpdfsdk/fpdfdoc_embeddertest.cpp

Issue 2636403003: Bad indexing in CPDF_Document::FindPageIndex when page tree corrupt. (Closed)
Patch Set: return -1 for out-of-range Created 3 years, 11 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
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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "core/fxcrt/fx_string.h" 8 #include "core/fxcrt/fx_string.h"
9 #include "public/fpdf_doc.h" 9 #include "public/fpdf_doc.h"
10 #include "public/fpdf_edit.h" 10 #include "public/fpdf_edit.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 EXPECT_TRUE( 61 EXPECT_TRUE(
62 FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom)); 62 FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &x, &y, &zoom));
63 EXPECT_TRUE(hasX); 63 EXPECT_TRUE(hasX);
64 EXPECT_TRUE(hasY); 64 EXPECT_TRUE(hasY);
65 EXPECT_TRUE(hasZoom); 65 EXPECT_TRUE(hasZoom);
66 EXPECT_EQ(0, x); 66 EXPECT_EQ(0, x);
67 EXPECT_EQ(0, y); 67 EXPECT_EQ(0, y);
68 EXPECT_EQ(1, zoom); 68 EXPECT_EQ(1, zoom);
69 } 69 }
70 70
71 TEST_F(FPDFDocEmbeddertest, BUG_680376) {
72 EXPECT_TRUE(OpenDocument("bug_680376.pdf"));
73
74 // Page number directly in item from Dests NameTree.
75 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), "First");
76 EXPECT_TRUE(dest);
77 EXPECT_EQ(static_cast<unsigned long>(-1),
78 FPDFDest_GetPageIndex(document(), dest));
79 }
80
71 TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) { 81 TEST_F(FPDFDocEmbeddertest, ActionGetFilePath) {
72 EXPECT_TRUE(OpenDocument("launch_action.pdf")); 82 EXPECT_TRUE(OpenDocument("launch_action.pdf"));
73 83
74 FPDF_PAGE page = FPDF_LoadPage(document(), 0); 84 FPDF_PAGE page = FPDF_LoadPage(document(), 0);
75 ASSERT_TRUE(page); 85 ASSERT_TRUE(page);
76 86
77 // The target action is nearly the size of the whole page. 87 // The target action is nearly the size of the whole page.
78 FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100); 88 FPDF_LINK link = FPDFLink_GetLinkAtPoint(page, 100, 100);
79 ASSERT_TRUE(link); 89 ASSERT_TRUE(link);
80 90
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel5))); 229 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel5)));
220 230
221 const FX_WCHAR kExpectedPageLabel6[] = L""; 231 const FX_WCHAR kExpectedPageLabel6[] = L"";
222 ASSERT_EQ(2u, FPDF_GetPageLabel(document(), 6, buf, sizeof(buf))); 232 ASSERT_EQ(2u, FPDF_GetPageLabel(document(), 6, buf, sizeof(buf)));
223 EXPECT_EQ(CFX_WideString(kExpectedPageLabel6), 233 EXPECT_EQ(CFX_WideString(kExpectedPageLabel6),
224 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel6))); 234 CFX_WideString::FromUTF16LE(buf, FXSYS_len(kExpectedPageLabel6)));
225 235
226 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 7, buf, sizeof(buf))); 236 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 7, buf, sizeof(buf)));
227 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 8, buf, sizeof(buf))); 237 ASSERT_EQ(0u, FPDF_GetPageLabel(document(), 8, buf, sizeof(buf)));
228 } 238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698