Fix a potential memory leak

Bug: 65648324
Test: Built without seeing the warnings
Change-Id: I934509c78482af9ef7dc447c807f6450484b4b38
(cherry picked from commit f26cf6d520)
This commit is contained in:
Ting-Yuan Huang 2017-08-15 15:07:21 -07:00 committed by Josh Gao
parent c03127ef5c
commit c4c0a7136b
1 changed files with 7 additions and 1 deletions

View File

@ -481,11 +481,17 @@ asocket* host_service_to_socket(const char* name, const char* serial, TransportI
return nullptr;
}
int fd = create_service_thread(wait_for_state, sinfo.release());
int fd = create_service_thread(wait_for_state, sinfo.get());
if (fd != -1) {
sinfo.release();
}
return create_local_socket(fd);
} else if (!strncmp(name, "connect:", 8)) {
char* host = strdup(name + 8);
int fd = create_service_thread(connect_service, host);
if (fd == -1) {
free(host);
}
return create_local_socket(fd);
}
return NULL;