Fix code health issues in the CDM identified by Coverity

Bug: 323331064
Change-Id: Ic87b32c1f7996bd5bb31e99a5fc117c59e94a42c
This commit is contained in:
Ian Benz
2024-01-30 21:12:56 +00:00
committed by Robert Shih
parent 93c19cd8de
commit 2fabef5bc9
5 changed files with 12 additions and 9 deletions

View File

@@ -309,6 +309,7 @@ bool HttpSocket::Connect(int timeout_in_ms) {
if (socket_fd_ < 0) {
LOGE("Cannot open socket %s (port %s): errno = %d", domain_name_.c_str(),
port_.c_str(), GetError());
freeaddrinfo(addr_info);
return false;
}
@@ -318,6 +319,7 @@ bool HttpSocket::Connect(int timeout_in_ms) {
if (ioctlsocket(socket_fd_, FIONBIO, &mode) != 0) {
LOGE("ioctlsocket error %s (port %s), wsa error = %d", domain_name_.c_str(),
port_.c_str(), WSAGetLastError());
freeaddrinfo(addr_info);
CloseSocket();
return false;
}
@@ -326,12 +328,14 @@ bool HttpSocket::Connect(int timeout_in_ms) {
if (original_flags == -1) {
LOGE("fcntl error %s (port %s), errno = %d", domain_name_.c_str(),
port_.c_str(), errno);
freeaddrinfo(addr_info);
CloseSocket();
return false;
}
if (fcntl(socket_fd_, F_SETFL, original_flags | O_NONBLOCK) == -1) {
LOGE("fcntl error %s (port %s), errno = %d", domain_name_.c_str(),
port_.c_str(), errno);
freeaddrinfo(addr_info);
CloseSocket();
return false;
}