From 7bf816420aa79b23c37ad433183f01dc5af653fa Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 10 Oct 2018 17:27:33 +0000 Subject: Better test FPDFAction_* public functions. Update public documentation. Make implementation match documentation for bad argument types. Change-Id: I70aa3ccaf2580f81d6eb14c6fb4198374010a695 Reviewed-on: https://pdfium-review.googlesource.com/c/43690 Reviewed-by: Tom Sepez Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/fpdf_doc.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'fpdfsdk/fpdf_doc.cpp') diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp index 614462fa47..28c670c5dd 100644 --- a/fpdfsdk/fpdf_doc.cpp +++ b/fpdfsdk/fpdf_doc.cpp @@ -164,11 +164,14 @@ FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetType(FPDF_ACTION pDict) { FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTION pDict) { - if (!pDict) - return nullptr; CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return nullptr; + + unsigned long type = FPDFAction_GetType(pDict); + if (type != PDFACTION_GOTO && type != PDFACTION_REMOTEGOTO) + return nullptr; + CPDF_Action action(CPDFDictionaryFromFPDFAction(pDict)); return FPDFDestFromCPDFArray(action.GetDest(pDoc).GetArray()); } @@ -192,11 +195,14 @@ FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION pDict, void* buffer, unsigned long buflen) { - if (!pDict) - return 0; CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); if (!pDoc) return 0; + + unsigned long type = FPDFAction_GetType(pDict); + if (type != PDFACTION_URI) + return 0; + CPDF_Action action(CPDFDictionaryFromFPDFAction(pDict)); ByteString path = action.GetURI(pDoc); unsigned long len = path.GetLength() + 1; -- cgit v1.2.3