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 b199cdbe31e23dd09116b303257a17ad9bb687ee..f24a6c079c50948dbf4294f12512b71d511a269a 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 62651c00656194b8c2921553bc538a6b8a81a640..6135f178efe2fb6234ecf0960092e451ca39e49a 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) {