CJX_Xfa::thisValue() can be null when called from C++.
It won't be NULL when called from JS, but it may be directly
invoked on top of CXFA_Document::DoProtoMerge() without first
establishing a binding for |xfa.this|.
Bug: pdfium:1238
Change-Id: I91bf83a38f42ff2bde3077190e069168d1c937dd
Reviewed-on: https://pdfium-review.googlesource.com/c/50910
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_xfa.cpp b/fxjs/xfa/cjx_xfa.cpp
index 7de690f..2d943bd 100644
--- a/fxjs/xfa/cjx_xfa.cpp
+++ b/fxjs/xfa/cjx_xfa.cpp
@@ -25,7 +25,11 @@
if (bSetting)
return;
- CXFA_Object* pThis = GetDocument()->GetScriptContext()->GetThisObject();
- ASSERT(pThis);
- pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(pThis));
+ auto* pScriptContext = GetDocument()->GetScriptContext();
+ CXFA_Object* pThis = pScriptContext->GetThisObject();
+ if (!pThis) {
+ pValue->SetNull();
+ return;
+ }
+ pValue->Assign(pScriptContext->GetJSValueFromMap(pThis));
}