Fix fd leak case 61/303861/2
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 8 Jan 2024 01:40:50 +0000 (10:40 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Mon, 8 Jan 2024 02:12:28 +0000 (11:12 +0900)
Change-Id: I46906a131388833e06f256be7845f65f0b45c244
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
aul/socket/server_socket.cc

index b5bbc9d..1a9136c 100644 (file)
@@ -54,7 +54,14 @@ ClientSocket* ServerSocket::Accept() {
     return nullptr;
   }
 
-  return new (std::nothrow) ClientSocket(client_fd);
+  ClientSocket* client = new (std::nothrow) ClientSocket(client_fd);
+  if (client == nullptr) {
+    _E("Out of memory");
+    close(client_fd);
+    return nullptr;
+  }
+
+  return client;
 }
 
 void ServerSocket::Bind(const std::string& bindpoint) {