From 5e8c117660da1b3dafccb88088b0286442a11f72 Mon Sep 17 00:00:00 2001 From: jusung son Date: Tue, 10 Sep 2024 12:55:11 +0900 Subject: [PATCH] Fix memory leak Change-Id: I85a3130cbb53d8eaa94010042b3bfb818c3111da Signed-off-by: jusung son --- src/rpc-port/client-channel-internal.cc | 4 ++-- src/rpc-port/client-channel-internal.hh | 2 +- src/rpc-port/proxy-internal.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpc-port/client-channel-internal.cc b/src/rpc-port/client-channel-internal.cc index 959ffd2..345a7b0 100644 --- a/src/rpc-port/client-channel-internal.cc +++ b/src/rpc-port/client-channel-internal.cc @@ -32,7 +32,7 @@ ClientChannel::ClientChannel(IEvent* listener) : listener_(listener) {} ClientChannel::~ClientChannel() { GLib::SourceDestroy(source_); } -ClientChannel* ClientChannel::Create(IEvent* listener, +std::unique_ptr ClientChannel::Create(IEvent* listener, const std::string& endpoint) { try { std::unique_ptr client = @@ -61,7 +61,7 @@ ClientChannel* ClientChannel::Create(IEvent* listener, client->SetReceiveTimeout(rpc_port_get_timeout()); _W("endpoint(%s), fd(%d)", endpoint.c_str(), client->GetFd()); - return client.release(); + return client; } catch (const Exception& e) { // LCOV_EXCL_START _E("Exception(%s) occurs", e.what()); diff --git a/src/rpc-port/client-channel-internal.hh b/src/rpc-port/client-channel-internal.hh index e664d46..22f0b99 100644 --- a/src/rpc-port/client-channel-internal.hh +++ b/src/rpc-port/client-channel-internal.hh @@ -38,7 +38,7 @@ class ClientChannel : public ClientSocket { explicit ClientChannel(IEvent* listener); virtual ~ClientChannel(); - static ClientChannel* Create(IEvent* listener, const std::string& endpoint); + static std::unique_ptr Create(IEvent* listener, const std::string& endpoint); int Watch(); private: diff --git a/src/rpc-port/proxy-internal.cc b/src/rpc-port/proxy-internal.cc index 3734b7c..98baae5 100644 --- a/src/rpc-port/proxy-internal.cc +++ b/src/rpc-port/proxy-internal.cc @@ -109,7 +109,7 @@ int Proxy::CreateClientChannel(std::string instance, std::string port_type, if (ret != 0) return RPC_PORT_ERROR_IO_ERROR; } - channel->reset(client); + channel->reset(client.release()); return RPC_PORT_ERROR_NONE; } -- 2.34.1