From 01401823fb36026cf2b605b80923ca9a44949b3f Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Tue, 17 May 2016 15:14:25 -0700 Subject: [PATCH] adb: check return value of register_socket_transport. Change-Id: I45e30861cf292323e3264a815e4ffd23d6610c52 --- adb/transport_local.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index 4121f472c..c1c88a99c 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -167,7 +167,9 @@ static void server_socket_thread(void* arg) { D("server: new connection on fd %d", fd); close_on_exec(fd); disable_tcp_nagle(fd); - register_socket_transport(fd, "host", port, 1); + if (register_socket_transport(fd, "host", port, 1) != 0) { + adb_close(fd); + } } } D("transport: server_socket_thread() exiting"); @@ -261,8 +263,8 @@ static void qemu_socket_thread(void* arg) { /* Host is connected. Register the transport, and start the * exchange. */ std::string serial = android::base::StringPrintf("host-%d", fd); - register_socket_transport(fd, serial.c_str(), port, 1); - if (!WriteFdExactly(fd, _start_req, strlen(_start_req))) { + if (register_socket_transport(fd, serial.c_str(), port, 1) != 0 || + !WriteFdExactly(fd, _start_req, strlen(_start_req))) { adb_close(fd); } }