Fix leaks

This commit is contained in:
Nick Krichevsky 2018-09-03 00:33:33 -04:00
parent f7d469bb00
commit 10cff3572b
3 changed files with 4 additions and 1 deletions

View file

@ -66,4 +66,5 @@ void get_parts(const char *dest, char *path_buffer, char *host_buffer) {
}
strcpy(path_buffer, slash_cursor);
strncpy(host_buffer, dest, slash_cursor - dest);
host_buffer[slash_cursor - dest] = '\0';
}

View file

@ -142,6 +142,9 @@ enum socket_read_result send_request(struct http_message req, struct response_in
res_info->rtt = end_time - start_time;
res_info->contents = res.contents;
close(socket_fd);
free(res.start_line);
free_headers(res.headers);
freeaddrinfo(addr_info);
return result;
}

View file

@ -86,7 +86,6 @@ static struct line_read_result read_line(const char *buffer, int buffer_size, st
result.line_type = RESULT_START_LINE;
message->start_line = malloc((line_size + 1) * sizeof(char));
strcpy(message->start_line, result.line);
message->start_line = result.line;
}
return result;