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

Unified 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: nit 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 side-by-side diff with in-line comments
Download patch
« core/src/fpdftext/fpdf_text_int.cpp ('K') | « fpdfsdk/src/fpdftext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdftext_embeddertest.cpp
diff --git a/fpdfsdk/src/fpdftext_embeddertest.cpp b/fpdfsdk/src/fpdftext_embeddertest.cpp
index 4653db32ad580a0272e8c2c3803360285ca9c897..e84a96e966797f14b9e9f97dfab6de81404b1316 100644
--- a/fpdfsdk/src/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/src/fpdftext_embeddertest.cpp
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "core/include/fxcrt/fx_basic.h"
#include "public/fpdf_text.h"
#include "public/fpdfview.h"
#include "testing/embedder_test.h"
@@ -10,9 +11,9 @@
namespace {
-static bool check_unsigned_shorts(const char* expected,
- const unsigned short* actual,
- size_t length) {
+bool check_unsigned_shorts(const char* expected,
+ const unsigned short* actual,
+ size_t length) {
if (length > strlen(expected) + 1) {
return false;
}
@@ -367,3 +368,24 @@ TEST_F(FPDFTextEmbeddertest, WebLinks) {
FPDFText_ClosePage(textpage);
UnloadPage(page);
}
+
+TEST_F(FPDFTextEmbeddertest, GetFontSize) {
+ EXPECT_TRUE(OpenDocument("hello_world.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ EXPECT_NE(nullptr, page);
+
+ FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page);
+ EXPECT_NE(nullptr, textpage);
+
+ const double kExpectedFontsSizes[] = {12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 1, 1, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
+
+ int count = FPDFText_CountChars(textpage);
+ ASSERT_EQ(FX_ArraySize(kExpectedFontsSizes), count);
+ for (int i = 0; i < count; ++i)
+ EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i;
+
+ FPDFText_ClosePage(textpage);
+ UnloadPage(page);
+}
« core/src/fpdftext/fpdf_text_int.cpp ('K') | « fpdfsdk/src/fpdftext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698