Fix a crash in CXFA_FFDocView::RunBindItems().

BUG=pdfium:1272

Change-Id: Ie1adb79745c2b4fef04f0116b910dd0e03392d26
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52190
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/testing/resources/pixel/xfa_specific/bug_1272.in b/testing/resources/pixel/xfa_specific/bug_1272.in
new file mode 100644
index 0000000..290e5d4
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1272.in
@@ -0,0 +1,18 @@
+{{header}}
+{{include ../../xfa_catalog_1_0.fragment}}
+{{include ../../xfa_object_single_2_0.fragment}}
+{{object 3 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+<template>
+<subform use=" .[$.clone(1)]">
+<bindItems>
+endstream
+endobj
+{{include ../../xfa_pages_8_0.fragment}}
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/xfa_specific/bug_1272_expected.pdf.0.png b/testing/resources/pixel/xfa_specific/bug_1272_expected.pdf.0.png
new file mode 100644
index 0000000..08c11b0
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/bug_1272_expected.pdf.0.png
Binary files differ
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 6f61f0c..a346abe 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -601,7 +601,7 @@
       continue;
 
     CXFA_Node* pWidgetNode = item->GetParent();
-    if (!pWidgetNode->IsWidgetReady())
+    if (!pWidgetNode || !pWidgetNode->IsWidgetReady())
       continue;
 
     CFXJSE_Engine* pScriptContext =