summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/cjs_runtime.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index 7d3808a61d..539594cd90 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -201,8 +201,13 @@ bool CJS_Runtime::GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
v8::String::NewFromUtf8(GetIsolate(), utf8Name.unterminated_c_str(),
v8::NewStringType::kNormal, utf8Name.GetLength())
.ToLocalChecked();
- v8::Local<v8::Value> propvalue =
- context->Global()->Get(context, str).ToLocalChecked();
+ v8::MaybeLocal<v8::Value> maybe_propvalue =
+ context->Global()->Get(context, str);
+ if (maybe_propvalue.IsEmpty()) {
+ pValue->SetUndefined();
+ return false;
+ }
+ v8::Local<v8::Value> propvalue = maybe_propvalue.ToLocalChecked();
if (propvalue.IsEmpty()) {
pValue->SetUndefined();
return false;