Fix fd leak case 60/303860/1
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 8 Jan 2024 01:40:23 +0000 (10:40 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Mon, 8 Jan 2024 01:40:23 +0000 (10:40 +0900)
Change-Id: I6a8db3277d648c779393d54145a6a353436e792a
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
component_based/port/server.cc

index 9d59c7902ecfc8f64e037c549bed357e2e144421..a1b0c003fdd4cd953eadec6377181c9549a75f60 100644 (file)
@@ -120,7 +120,14 @@ Client* Server::Accept() {
   }
 
   _W("client pid(%d), uid(%u)", cred.pid, cred.uid);
-  return new (std::nothrow) Client(client_fd, cred.pid);
+  Client* client = new (std::nothrow) Client(client_fd, cred.pid);
+  if (client == nullptr) {
+    _E("Out of memory");
+    close(client_fd);
+    return nullptr;
+  }
+
+  return client;
 }
 
 int Server::CheckPrivilege(int fd) {