Skip to content

Commit f7e92fd

Browse files
committed
Cleans creating the TLS request string length and buffer.
1 parent 6b7f887 commit f7e92fd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

main/https_client.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,13 @@ static http_err_t https_create_context_for_request(http_request_context_t **http
386386
ctx->request = httpRequest;
387387

388388
// Create the TLS request string.
389-
390-
size_t requestLen = strlen(http_get_request_format_string) + strlen(httpRequest->host) + strlen(httpRequest->path) - 4 + 1;
391-
389+
390+
size_t requestLen = strlen(http_get_request_format_string) - 4 // strlen("%s%s") = 4
391+
+ strlen(httpRequest->host) + strlen(httpRequest->path);
392+
392393
ctx->tls_request_buffer_size = requestLen;
393-
ctx->tls_request_buffer = malloc(requestLen);
394-
394+
ctx->tls_request_buffer = malloc(ctx->tls_request_buffer_size * sizeof(char));
395+
395396
if (!ctx->tls_request_buffer) {
396397
ESP_LOGE(TAG, "https_create_context_for_request: failed to allocate TLS request buffer");
397398
https_destroy_context(ctx);

0 commit comments

Comments
 (0)