diff options
author | Lei Zhang <thestig@chromium.org> | 2017-10-20 17:23:40 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-21 05:05:12 +0000 |
commit | d78ef3b7c9435f5e066da970da7f28b598b07866 (patch) | |
tree | bd1e5756edf622d4a0b949dbf2eaa73b20713b67 /fpdfsdk/fpdfdoc_embeddertest.cpp | |
parent | d0b48fa54263ac6d5bdd3d7ffadfb7010b9c77da (diff) | |
download | pdfium-d78ef3b7c9435f5e066da970da7f28b598b07866.tar.xz |
Fix a FPDF_GetMetaText() crash.
With a newly created document, there is no parser. CPDF_Document is
missing a nullptr check which can be triggered via FPDF_GetMetaText().
BUG=pdfium:915
Change-Id: If9a300a6dc2ca5914c3544eae5c27fe3139dd821
Reviewed-on: https://pdfium-review.googlesource.com/16490
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfdoc_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdfdoc_embeddertest.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfdoc_embeddertest.cpp b/fpdfsdk/fpdfdoc_embeddertest.cpp index 19147d4bae..c691a17a11 100644 --- a/fpdfsdk/fpdfdoc_embeddertest.cpp +++ b/fpdfsdk/fpdfdoc_embeddertest.cpp @@ -237,6 +237,13 @@ TEST_F(FPDFDocEmbeddertest, GetMetaTextInAttachmentFile) { WideString::FromUTF16LE(buf, FXSYS_len(kExpectedModDate))); } +TEST_F(FPDFDocEmbeddertest, GetMetaTextFromNewDocument) { + FPDF_DOCUMENT empty_doc = FPDF_CreateNewDocument(); + unsigned short buf[128]; + EXPECT_EQ(2u, FPDF_GetMetaText(empty_doc, "Title", buf, sizeof(buf))); + FPDF_CloseDocument(empty_doc); +} + TEST_F(FPDFDocEmbeddertest, NoPageLabels) { EXPECT_TRUE(OpenDocument("about_blank.pdf")); EXPECT_EQ(1, FPDF_GetPageCount(document())); |