fix(http): response len

This commit is contained in:
2025-10-17 02:02:41 +02:00
parent 78ebc7b6d0
commit 8743617649
2 changed files with 10 additions and 6 deletions

View File

@@ -274,9 +274,9 @@ size_t http_response_builder(char **response, cws_http_status_e status, char *co
char *status_code = http_status_string(status);
size_t header_len = http_header_len(status_code, content_type, body_len_bytes);
size_t total_len = header_len + body_len_bytes + 1;
size_t total_len = header_len + body_len_bytes;
*response = malloc(total_len);
*response = malloc(total_len + 1);
if (*response == NULL) {
return 0;
}
@@ -288,6 +288,8 @@ size_t http_response_builder(char **response, cws_http_status_e status, char *co
memcpy(*response + header_len, body, body_len_bytes);
}
(*response)[total_len] = '\0';
return total_len;
}