summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdftext_embeddertest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdftext_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdftext_embeddertest.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp
index e662bbe6e5..a83ffe7c29 100644
--- a/fpdfsdk/fpdftext_embeddertest.cpp
+++ b/fpdfsdk/fpdftext_embeddertest.cpp
@@ -43,6 +43,12 @@ TEST_F(FPDFTextEmbeddertest, Text) {
unsigned short fixed_buffer[128];
memset(fixed_buffer, 0xbd, sizeof(fixed_buffer));
+ // Check that unreasonable inputs are handled gracefully
+ EXPECT_EQ(0, FPDFText_GetText(textpage, 0, 128, nullptr));
+ EXPECT_EQ(0, FPDFText_GetText(textpage, -1, 128, fixed_buffer));
+ EXPECT_EQ(0, FPDFText_GetText(textpage, 0, 0, fixed_buffer));
+ EXPECT_EQ(0, FPDFText_GetText(textpage, 0, -1, fixed_buffer));
+
// Check includes the terminating NUL that is provided.
int num_chars = FPDFText_GetText(textpage, 0, 128, fixed_buffer);
ASSERT_GE(num_chars, 0);