Fix a crash inside CJX_HostPseudoModel::openList().

BUG=pdfium:1256

Change-Id: I61e831ae6134e8624cdec2fc82bf0c619141fcc5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51771
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/BUILD.gn b/fxjs/BUILD.gn
index ecaf20c..e53e940 100644
--- a/fxjs/BUILD.gn
+++ b/fxjs/BUILD.gn
@@ -251,6 +251,7 @@
         "xfa/cfxjse_app_embeddertest.cpp",
         "xfa/cfxjse_formcalc_context_embeddertest.cpp",
         "xfa/cfxjse_value_embeddertest.cpp",
+        "xfa/cjx_hostpseudomodel_embeddertest.cpp",
       ]
       deps += [ "..///xfa/fxfa" ]
     }
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 2f5ffd8..109f743 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -298,6 +298,9 @@
     pNode = resolveNodeRS.objects.front()->AsNode();
   }
 
+  if (!pNode)
+    return CJS_Result::Success();
+
   CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
   CXFA_FFWidget* hWidget =
       XFA_GetWidgetFromLayoutItem(pDocLayout->GetLayoutItem(pNode));
diff --git a/fxjs/xfa/cjx_hostpseudomodel_embeddertest.cpp b/fxjs/xfa/cjx_hostpseudomodel_embeddertest.cpp
new file mode 100644
index 0000000..1d42898
--- /dev/null
+++ b/fxjs/xfa/cjx_hostpseudomodel_embeddertest.cpp
@@ -0,0 +1,15 @@
+// Copyright 2019 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/xfa_js_embedder_test.h"
+
+class CJX_HostPseudoModelEmbedderTest : public XFAJSEmbedderTest {};
+
+// Should not crash.
+TEST_F(CJX_HostPseudoModelEmbedderTest, BUG_1256) {
+  ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
+
+  EXPECT_TRUE(Execute("$host.openList(1)"));
+}