Fix some memory leaks
parent
cb16b2fcd0
commit
6ba3ee9756
|
@ -190,10 +190,28 @@ enum socket_result serve_one_request(int sock_fd) {
|
|||
enum socket_result read_result = get_all_remote_parts(client_fd, TYPE_SERVER, &message);
|
||||
if (read_result == RESULT_MALFORMED) {
|
||||
send_headers(400, client_fd, -1);
|
||||
if (message.start_line != NULL) {
|
||||
free(message.start_line);
|
||||
}
|
||||
if (message.contents != NULL) {
|
||||
free(message.contents);
|
||||
}
|
||||
if (message.headers != NULL) {
|
||||
free_headers(message.headers);
|
||||
}
|
||||
close(client_fd);
|
||||
return RESULT_MALFORMED;
|
||||
} else if (read_result != RESULT_OK){
|
||||
send_headers(500, client_fd, -1);
|
||||
if (message.start_line != NULL) {
|
||||
free(message.start_line);
|
||||
}
|
||||
if (message.contents != NULL) {
|
||||
free(message.contents);
|
||||
}
|
||||
if (message.headers != NULL) {
|
||||
free_headers(message.headers);
|
||||
}
|
||||
close(client_fd);
|
||||
return RESULT_READ_ERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue