diff --git a/frameworks/ets/ani/src/manager/ani_local_live_view.cpp b/frameworks/ets/ani/src/manager/ani_local_live_view.cpp index a677c8be485fb2f93a42bdcd44a418fd512eed5b..1f607f24693f19226bb751b384e2ad5bed6cdaa1 100644 --- a/frameworks/ets/ani/src/manager/ani_local_live_view.cpp +++ b/frameworks/ets/ani/src/manager/ani_local_live_view.cpp @@ -66,6 +66,9 @@ void AniSubscribeSystemLiveView(ani_env *env, ani_object subscriberObj) int returncode = OHOS::Notification::NotificationHelper::SubscribeLocalLiveViewNotification( *localLiveViewSubscriber, false); if (returncode != ERR_OK) { + if (localLiveViewSubscriber != nullptr) { + delete localLiveViewSubscriber; + } int externalCode = NotificationSts::GetExternalCode(returncode); OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode)); ANS_LOGE("AniSubscribeSystemLiveView error, errorCode: %{public}d", externalCode);