From f864307cee35ed0f48f44a53bd31d72d17680334 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 19 Aug 2025 20:08:15 +0800 Subject: [PATCH] fix want Signed-off-by: zhangzezhong --- .../ets/ani/ani_common/src/ani_common_util.cpp | 13 ------------- frameworks/ets/ani/wantagent/src/ani_want_agent.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/frameworks/ets/ani/ani_common/src/ani_common_util.cpp b/frameworks/ets/ani/ani_common/src/ani_common_util.cpp index b199cdbe31e..f24a6c079c5 100644 --- a/frameworks/ets/ani/ani_common/src/ani_common_util.cpp +++ b/frameworks/ets/ani/ani_common/src/ani_common_util.cpp @@ -182,19 +182,6 @@ bool SetFieldStringByName(ani_env *env, ani_class cls, ani_object object, const TAG_LOGE(AAFwkTag::ANI, "status: %{public}d", status); return false; } - - if (value.empty()) { - ani_ref nullRef = nullptr; - if ((status = env->GetNull(&nullRef)) != ANI_OK) { - TAG_LOGE(AAFwkTag::ANI, "status: %{public}d", status); - return false; - } - if ((status = env->Object_SetField_Ref(object, field, nullRef)) != ANI_OK) { - TAG_LOGE(AAFwkTag::ANI, "status: %{public}d", status); - return false; - } - return true; - } ani_string aniStr = nullptr; if ((status = env->String_NewUTF8(value.c_str(), value.size(), &aniStr)) != ANI_OK) { TAG_LOGE(AAFwkTag::ANI, "status: %{public}d", status); diff --git a/frameworks/ets/ani/wantagent/src/ani_want_agent.cpp b/frameworks/ets/ani/wantagent/src/ani_want_agent.cpp index 62651c00656..6135f178efe 100644 --- a/frameworks/ets/ani/wantagent/src/ani_want_agent.cpp +++ b/frameworks/ets/ani/wantagent/src/ani_want_agent.cpp @@ -138,6 +138,12 @@ void TriggerCompleteCallBack::OnSendFinished( dataWorker->call = triggerCompleteInfo_.call; if (triggerCompleteInfo_.wantAgent != nullptr) { dataWorker->wantAgent = new (std::nothrow) WantAgent(triggerCompleteInfo_.wantAgent->GetPendingWant()); + if (dataWorker->wantAgent == nullptr) { + TAG_LOGE(AAFwkTag::WANTAGENT, "null wantAgent"); + delete dataWorker; + dataWorker = nullptr; + return; + } } if (!OnSendFinishedCallback(dataWorker)) { if (dataWorker->wantAgent != nullptr) { -- Gitee