Fix memory leak 05/317405/1
authorjusung son <jusung07.son@samsung.com>
Tue, 10 Sep 2024 03:55:11 +0000 (12:55 +0900)
committerjusung son <jusung07.son@samsung.com>
Tue, 10 Sep 2024 03:55:11 +0000 (12:55 +0900)
Change-Id: I85a3130cbb53d8eaa94010042b3bfb818c3111da
Signed-off-by: jusung son <jusung07.son@samsung.com>
src/rpc-port/client-channel-internal.cc
src/rpc-port/client-channel-internal.hh
src/rpc-port/proxy-internal.cc

index 959ffd2a01983f3eb5f314d7fb0578d963726219..345a7b01880009dcca4c6eb5f1c6b5f2c8af3114 100644 (file)
@@ -32,7 +32,7 @@ ClientChannel::ClientChannel(IEvent* listener) : listener_(listener) {}
 
 ClientChannel::~ClientChannel() { GLib::SourceDestroy(source_); }
 
-ClientChannel* ClientChannel::Create(IEvent* listener,
+std::unique_ptr<ClientChannel> ClientChannel::Create(IEvent* listener,
                                      const std::string& endpoint) {
   try {
     std::unique_ptr<ClientChannel> 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());
index e664d46fcc0333cba50b9659e623acc8a2f92150..22f0b992ceea5a6cc2782e02beac9399d8cb27fd 100644 (file)
@@ -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<ClientChannel> Create(IEvent* listener, const std::string& endpoint);
   int Watch();
 
  private:
index 3734b7c16370aa6ce8cf949619250a09564e0c61..98baae563ca795ac1fa14829e9c6fb86823d73a2 100644 (file)
@@ -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;
 }