From 76d01feaeec421ebe6005f22de85998220703dd2 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 8 Jun 2018 18:05:58 +0000 Subject: Do not crash if FPDFPage_Get{Media,Crop}Box() gets a NULL out parameter. Change-Id: I4b61d4c7239caaf6081bcba80cc0d8ad61569474 Reviewed-on: https://pdfium-review.googlesource.com/34590 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- fpdfsdk/fpdf_transformpage.cpp | 3 +++ fpdfsdk/fpdf_transformpage_embeddertest.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index a3ba7ca7a9..210c6b6fde 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp @@ -36,6 +36,9 @@ bool GetBoundingBox(CPDF_Page* page, float* bottom, float* right, float* top) { + if (!left || !bottom || !right || !top) + return false; + CPDF_Array* pArray = page->GetDict()->GetArrayFor(key); if (!pArray) return false; diff --git a/fpdfsdk/fpdf_transformpage_embeddertest.cpp b/fpdfsdk/fpdf_transformpage_embeddertest.cpp index d064efee0b..1ebd0f054c 100644 --- a/fpdfsdk/fpdf_transformpage_embeddertest.cpp +++ b/fpdfsdk/fpdf_transformpage_embeddertest.cpp @@ -66,6 +66,16 @@ TEST_F(FPDFTransformEmbedderTest, GetBoundingBoxes) { EXPECT_EQ(60, cropbox_right); EXPECT_EQ(60, cropbox_top); + EXPECT_FALSE(FPDFPage_GetCropBox(page, nullptr, &cropbox_bottom, + &cropbox_right, &cropbox_top)); + EXPECT_FALSE(FPDFPage_GetCropBox(page, &cropbox_left, nullptr, + &cropbox_right, &cropbox_top)); + EXPECT_FALSE(FPDFPage_GetCropBox(page, &cropbox_left, &cropbox_bottom, + nullptr, &cropbox_top)); + EXPECT_FALSE(FPDFPage_GetCropBox(page, &cropbox_left, &cropbox_bottom, + &cropbox_right, nullptr)); + EXPECT_FALSE(FPDFPage_GetCropBox(page, nullptr, nullptr, nullptr, nullptr)); + UnloadPage(page); } } -- cgit v1.2.3