adb: fix fd leak when shell fails to create a thread.

Bug: http://b/29565233
Change-Id: Ia59c6dbe5ac033425c11739579e85cbcad1170d1
This commit is contained in:
Josh Gao 2016-06-23 11:21:11 -07:00
parent cd5d7376dc
commit e31a7a4ce4
1 changed files with 4 additions and 3 deletions

View File

@ -756,13 +756,14 @@ int StartSubprocess(const char* name, const char* terminal_type,
return ReportError(protocol, error);
}
int local_socket = subprocess->ReleaseLocalSocket();
D("subprocess creation successful: local_socket_fd=%d, pid=%d", local_socket, subprocess->pid());
unique_fd local_socket(subprocess->ReleaseLocalSocket());
D("subprocess creation successful: local_socket_fd=%d, pid=%d", local_socket.get(),
subprocess->pid());
if (!Subprocess::StartThread(std::move(subprocess), &error)) {
LOG(ERROR) << "failed to start subprocess management thread: " << error;
return ReportError(protocol, error);
}
return local_socket;
return local_socket.release();
}