Merge "adb: check return value of register_socket_transport." am: 3d981c87c9 am: 1a78ec8f65
am: bb89e7e6b5
* commit 'bb89e7e6b5403297689f62b8f86d7a3cbab4037e':
adb: check return value of register_socket_transport.
Change-Id: I7394d2fc85fd49f846ae96affc78a83601db9bc0
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp
index 4f3e1f5..63d36c0 100644
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -172,7 +172,9 @@
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");
@@ -266,8 +268,8 @@
/* 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);
}
}