Fix some memory leaks
This commit is contained in:
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);
|
enum socket_result read_result = get_all_remote_parts(client_fd, TYPE_SERVER, &message);
|
||||||
if (read_result == RESULT_MALFORMED) {
|
if (read_result == RESULT_MALFORMED) {
|
||||||
send_headers(400, client_fd, -1);
|
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);
|
close(client_fd);
|
||||||
return RESULT_MALFORMED;
|
return RESULT_MALFORMED;
|
||||||
} else if (read_result != RESULT_OK){
|
} else if (read_result != RESULT_OK){
|
||||||
send_headers(500, client_fd, -1);
|
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);
|
close(client_fd);
|
||||||
return RESULT_READ_ERROR;
|
return RESULT_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue