未验证 提交 c0e28bfe 编写于 作者: O openharmony_ci 提交者: Gitee

!661 修复OnRemoteDied中断言失败crash问题

Merge pull request !661 from dengliang/master
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
bool Matches(napi_value object); bool Matches(napi_value object);
protected: protected:
virtual ~NAPIDeathRecipient(); virtual ~NAPIDeathRecipient() = default;
private: private:
struct OnRemoteDiedParam { struct OnRemoteDiedParam {
......
...@@ -33,17 +33,6 @@ NAPIDeathRecipient::NAPIDeathRecipient(napi_env env, napi_value jsDeathRecipient ...@@ -33,17 +33,6 @@ NAPIDeathRecipient::NAPIDeathRecipient(napi_env env, napi_value jsDeathRecipient
NAPI_ASSERT_RETURN_VOID(env, status == napi_ok, "failed to create ref to js death recipient"); NAPI_ASSERT_RETURN_VOID(env, status == napi_ok, "failed to create ref to js death recipient");
} }
NAPIDeathRecipient::~NAPIDeathRecipient()
{
if (env_ != nullptr) {
if (deathRecipientRef_ != nullptr) {
napi_status status = napi_delete_reference(env_, deathRecipientRef_);
NAPI_ASSERT_RETURN_VOID(env_, status == napi_ok, "failed to delete ref to js death recipient");
deathRecipientRef_ = nullptr;
}
}
}
void NAPIDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object) void NAPIDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
{ {
if (deathRecipientRef_ == nullptr) { if (deathRecipientRef_ == nullptr) {
...@@ -78,6 +67,9 @@ void NAPIDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object) ...@@ -78,6 +67,9 @@ void NAPIDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
if (returnVal == nullptr) { if (returnVal == nullptr) {
ZLOGE(LOG_LABEL, "failed to call function onRemoteDied"); ZLOGE(LOG_LABEL, "failed to call function onRemoteDied");
} }
napi_status napiStatus = napi_delete_reference(param->env, param->deathRecipientRef);
NAPI_ASSERT_RETURN_VOID(param->env, napiStatus == napi_ok, "failed to delete ref to js death recipient");
delete param; delete param;
delete work; delete work;
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册