More frees

master
Nick Krichevsky 2018-09-11 16:00:31 -04:00
parent 4895b252e9
commit 0591261fd5
1 changed files with 4 additions and 0 deletions

View File

@ -107,6 +107,7 @@ enum socket_result send_request(struct http_message req, struct response_info *r
int socket_fd = socket(addr_info->ai_family, addr_info->ai_socktype, addr_info->ai_protocol);
if (socket_fd < 0) {
freeaddrinfo(addr_info);
return RESULT_READ_ERROR;
}
@ -116,12 +117,14 @@ enum socket_result send_request(struct http_message req, struct response_info *r
// Initialize the time before beginning our connection
int start_time_result = gettimeofday(&pre_connect_time, NULL);
if (start_time_result != 0) {
freeaddrinfo(addr_info);
close(socket_fd);
return RESULT_PROCESSING_ERROR;
}
//Connect to the socket.
int connection_status = connect(socket_fd, addr_info->ai_addr, addr_info->ai_addrlen);
if (connection_status != 0) {
freeaddrinfo(addr_info);
close(socket_fd);
return RESULT_READ_ERROR;
}
@ -129,6 +132,7 @@ enum socket_result send_request(struct http_message req, struct response_info *r
//Get the end time of the connection
int end_time_result = gettimeofday(&post_connect_time, NULL);
if (end_time_result != 0) {
freeaddrinfo(addr_info);
close(socket_fd);
return RESULT_PROCESSING_ERROR;
}