diff --git a/cobalt/script/v8c/v8c_exception_state.cc b/cobalt/script/v8c/v8c_exception_state.cc index ee9fbe0e816a..ee4709955d47 100644 --- a/cobalt/script/v8c/v8c_exception_state.cc +++ b/cobalt/script/v8c/v8c_exception_state.cc @@ -70,6 +70,7 @@ void V8cExceptionState::SetException( V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate_); + if (!global_environment) return; v8::Local wrapper = global_environment->wrapper_factory()->GetWrapper(exception); diff --git a/cobalt/script/v8c/v8c_global_environment.cc b/cobalt/script/v8c/v8c_global_environment.cc index 9ec5c073b3e6..04e94d1cd3d7 100644 --- a/cobalt/script/v8c/v8c_global_environment.cc +++ b/cobalt/script/v8c/v8c_global_environment.cc @@ -378,7 +378,7 @@ V8cGlobalEnvironment::ModifyCodeGenerationFromStringsCallback( V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(context->GetIsolate()); DCHECK(global_environment); - if (!global_environment->report_eval_.is_null()) { + if (global_environment && !global_environment->report_eval_.is_null()) { global_environment->report_eval_.Run(); } // This callback should only be called while code generation from strings is @@ -396,7 +396,8 @@ void V8cGlobalEnvironment::MessageHandler(v8::Local message, v8::Isolate* isolate = v8::Isolate::GetCurrent(); V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); - if (isolate->GetEnteredOrMicrotaskContext().IsEmpty()) { + if (!global_environment || + isolate->GetEnteredOrMicrotaskContext().IsEmpty()) { return; } if (message->ErrorLevel() != v8::Isolate::kMessageError) {