Skip to content

Heap optimization #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions libraries/WiFiClientSecure/src/ssl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "Arduino.h"
#include <esp32-hal-log.h>
#include <lwip/sockets.h>
#include <lwip/err.h>
#include <lwip/sockets.h>
#include <lwip/sys.h>
Expand Down Expand Up @@ -181,6 +180,18 @@ int start_ssl_client(sslclient_context *ssl_client, uint32_t ipAddress, uint32_t
} else {
log_i("Certificate verified.");
}

if (rootCABuff != NULL) {
mbedtls_x509_crt_free(&ssl_client->ca_cert);
}

if (cli_cert != NULL) {
mbedtls_x509_crt_free(&ssl_client->client_cert);
}

if (cli_key != NULL) {
mbedtls_pk_free(&ssl_client->client_key);
}

log_i("Free heap after TLS %u", xPortGetFreeHeapSize());

Expand All @@ -201,18 +212,6 @@ void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, cons
mbedtls_ssl_config_free(&ssl_client->ssl_conf);
mbedtls_ctr_drbg_free(&ssl_client->drbg_ctx);
mbedtls_entropy_free(&ssl_client->entropy_ctx);

if (rootCABuff != NULL) {
mbedtls_x509_crt_free(&ssl_client->ca_cert);
}

if (cli_cert != NULL) {
mbedtls_x509_crt_free(&ssl_client->client_cert);
}

if (cli_key != NULL) {
mbedtls_pk_free(&ssl_client->client_key);
}
}


Expand Down