From 8c62883bdb9d695069a483133ddc96d5b85ec472 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 9 Oct 2018 21:02:15 +0000 Subject: Cover some more NULL-arg FPDFBookmark_* test cases Change-Id: I0a3db5368852eeed68bac317f8adaac4f54d023b Reviewed-on: https://pdfium-review.googlesource.com/c/43751 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/fpdf_doc.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'fpdfsdk/fpdf_doc.cpp') diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp index e7b9042479..e79c36e3e0 100644 --- a/fpdfsdk/fpdf_doc.cpp +++ b/fpdfsdk/fpdf_doc.cpp @@ -72,13 +72,13 @@ FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) { FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) { - if (!pDict) - return nullptr; - CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; + if (!pDict) + return nullptr; + CPDF_BookmarkTree tree(pDoc); CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict)); return FPDFBookmarkFromCPDFDictionary( @@ -96,11 +96,13 @@ FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void* buffer, unsigned long buflen) { FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { - if (!title || title[0] == 0) - return nullptr; CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; + + if (!title || title[0] == 0) + return nullptr; + CPDF_BookmarkTree tree(pDoc); size_t len = WideString::WStringLength(title); WideString encodedTitle = WideString::FromUTF16LE(title, len); @@ -111,11 +113,13 @@ FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) { - if (!pDict) - return nullptr; CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; + + if (!pDict) + return nullptr; + CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict)); CPDF_Dest dest = bookmark.GetDest(pDoc); if (dest.GetArray()) @@ -132,6 +136,7 @@ FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { if (!pDict) return nullptr; + CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict)); return FPDFActionFromCPDFDictionary(bookmark.GetAction().GetDict()); } -- cgit v1.2.3