diff --git a/bridge/bindings/qjs/script_wrappable.cc b/bridge/bindings/qjs/script_wrappable.cc index 30ac7990a3..ff88755750 100644 --- a/bridge/bindings/qjs/script_wrappable.cc +++ b/bridge/bindings/qjs/script_wrappable.cc @@ -316,8 +316,12 @@ void ScriptWrappable::ReleaseAlive() { if (alive_count == 0) { delete status_block_; status_block_ = nullptr; - context_->InActiveScriptWrappers(this); - JS_FreeValue(ctx_, jsObject_); + if (context_->IsContextValid()) { + context_->InActiveScriptWrappers(this); + } + if (context_->IsCtxValid()) { + JS_FreeValue(ctx_, jsObject_); + } } }