From 461ef4d3248a952d37716f5539f325962c6900d4 Mon Sep 17 00:00:00 2001 From: kaicui Date: Tue, 9 Sep 2025 16:55:05 +0800 Subject: [PATCH] Fix double free global reference problem Signed-off-by: kaicui --- .../window_stage_ani/src/ani_window_listener.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp index 1ed9addea4..0479766cb8 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window_listener.cpp @@ -27,8 +27,11 @@ using namespace AbilityRuntime; AniWindowListener::~AniWindowListener() { - ani_status ret = env_->GlobalReference_Delete(aniCallback_); - TLOGI(WmsLogTag::DEFAULT, "[ANI]~AniWindowListener ret:%{public}d", static_cast(ret)); + ani_status ret = ANI_OK; + if (env_ != nullptr && aniCallback_ != nullptr) { + ret = env_->GlobalReference_Delete(aniCallback_); + } + TLOGI(WmsLogTag::DEFAULT, "[ANI]~AniWindowListener ret: %{public}u", ret); } void AniWindowListener::OnLastStrongRef(const void *) -- Gitee