Fix segv above CPDFSDK_Document::GetPageView()
authorTom Sepez <tsepez@chromium.org>
Tue, 28 Jul 2015 18:08:51 +0000 (11:08 -0700)
committerTom Sepez <tsepez@chromium.org>
Tue, 28 Jul 2015 18:08:51 +0000 (11:08 -0700)
The refactoring at fb07e28 removed a null handle check.
BUG=514690
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1261923003 .

fpdfsdk/src/fpdfformfill.cpp
fpdfsdk/src/fpdfformfill_embeddertest.cpp

index d21d5d2..42e94c7 100644 (file)
@@ -27,6 +27,9 @@ CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle)
 
 CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page)
 {
+    if (!page)
+        return nullptr;
+
     CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
     return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr;
 }
index 615ada9..1c38770 100644 (file)
@@ -41,3 +41,15 @@ TEST_F(FPDFFormFillEmbeddertest, BUG_487928) {
   delegate.AdvanceTime(5000);
   UnloadPage(page);
 }
+
+TEST_F(FPDFFormFillEmbeddertest, BUG_514690) {
+  EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf"));
+  FPDF_PAGE page = LoadPage(0);
+  EXPECT_NE(nullptr, page);
+
+  // Test that FORM_OnMouseMove() etc. permit null HANDLES and PAGES.
+  FORM_OnMouseMove(nullptr, page, 0, 10.0, 10.0);
+  FORM_OnMouseMove(form_handle(), nullptr, 0, 10.0, 10.0);
+
+  UnloadPage(page);
+}