fix memory leaks and unecessary newlines in logs

This commit is contained in:
Nayan
2025-05-08 22:51:56 -04:00
parent 63a016cf36
commit 613e87ad86
4 changed files with 10 additions and 4 deletions

View File

@@ -68,11 +68,13 @@ void parse_http_request(char* request, int length, struct http_request* req) {
req->method = DELETE;
} else {
log_message(LOG_ERROR, "Invalid packet (method), cannot parse");
free(type);
return;
}
req->method_str = (char*)malloc(type_end - type_start + 1);
strncpy(req->method_str, type_start, type_end - type_start);
req->method_str[type_end - type_start] = '\0';
free(type);
// Extract URL
char* url_start = type_end + 1;