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

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

Issue 1578543002: Fix an uninitalized read in FPDFText_GetFontSize(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 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
« no previous file with comments | « fpdfsdk/src/fpdftext.cpp ('k') | no next file » | 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_basic.h"
5 #include "public/fpdf_text.h" 6 #include "public/fpdf_text.h"
6 #include "public/fpdfview.h" 7 #include "public/fpdfview.h"
7 #include "testing/embedder_test.h" 8 #include "testing/embedder_test.h"
8 #include "testing/test_support.h" 9 #include "testing/test_support.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace { 12 namespace {
12 13
13 static bool check_unsigned_shorts(const char* expected, 14 bool check_unsigned_shorts(const char* expected,
14 const unsigned short* actual, 15 const unsigned short* actual,
15 size_t length) { 16 size_t length) {
16 if (length > strlen(expected) + 1) { 17 if (length > strlen(expected) + 1) {
17 return false; 18 return false;
18 } 19 }
19 for (size_t i = 0; i < length; ++i) { 20 for (size_t i = 0; i < length; ++i) {
20 if (actual[i] != static_cast<unsigned short>(expected[i])) { 21 if (actual[i] != static_cast<unsigned short>(expected[i])) {
21 return false; 22 return false;
22 } 23 }
23 } 24 }
24 return true; 25 return true;
25 } 26 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 FPDFLink_GetRect(pagelink, -1, 0, &left, &top, &right, &bottom); 361 FPDFLink_GetRect(pagelink, -1, 0, &left, &top, &right, &bottom);
361 EXPECT_EQ(-2.0, left); 362 EXPECT_EQ(-2.0, left);
362 EXPECT_EQ(-2.0, right); 363 EXPECT_EQ(-2.0, right);
363 EXPECT_EQ(-2.0, bottom); 364 EXPECT_EQ(-2.0, bottom);
364 EXPECT_EQ(-2.0, top); 365 EXPECT_EQ(-2.0, top);
365 366
366 FPDFLink_CloseWebLinks(pagelink); 367 FPDFLink_CloseWebLinks(pagelink);
367 FPDFText_ClosePage(textpage); 368 FPDFText_ClosePage(textpage);
368 UnloadPage(page); 369 UnloadPage(page);
369 } 370 }
371
372 TEST_F(FPDFTextEmbeddertest, GetFontSize) {
373 EXPECT_TRUE(OpenDocument("hello_world.pdf"));
374 FPDF_PAGE page = LoadPage(0);
375 EXPECT_NE(nullptr, page);
376
377 FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page);
378 EXPECT_NE(nullptr, textpage);
379
380 const double kExpectedFontsSizes[] = {12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
381 12, 12, 12, 1, 1, 16, 16, 16, 16, 16,
382 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
383
384 int count = FPDFText_CountChars(textpage);
385 ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), count);
386 for (int i = 0; i < count; ++i)
387 EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i;
388
389 FPDFText_ClosePage(textpage);
390 UnloadPage(page);
391 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdftext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698