From 9176d5efccec41c56b83a2fd80c31a5195272a6c Mon Sep 17 00:00:00 2001 From: abc12133 Date: Wed, 28 Jun 2023 09:30:25 +0800 Subject: [PATCH] fix memory leak Signed-off-by: abc12133 --- window_manager/wm/src/window_adapter.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/window_manager/wm/src/window_adapter.cpp b/window_manager/wm/src/window_adapter.cpp index 23232c6..7a4b115 100644 --- a/window_manager/wm/src/window_adapter.cpp +++ b/window_manager/wm/src/window_adapter.cpp @@ -187,14 +187,16 @@ bool WindowAdapter::InitWMSProxy() return false; } - wmsDeath_ = new WMSDeathRecipient(); - if (!wmsDeath_) { - WLOGFE("Failed to create death Recipient ptr WMSDeathRecipient"); - return false; - } - if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(wmsDeath_)) { - WLOGFE("Failed to add death recipient"); - return false; + if (remoteObject->IsProxyObject()) { + wmsDeath_ = new WMSDeathRecipient(); + if (!wmsDeath_) { + WLOGFE("Failed to create death Recipient ptr WMSDeathRecipient"); + return false; + } + if (!remoteObject->AddDeathRecipient(wmsDeath_)) { + WLOGFE("Failed to add death recipient"); + return false; + } } isProxyValid_ = true; } -- Gitee