IDE examples: fix ssl double-free and unsafe connd close in servers

This commit is contained in:
Ruby Martin
2026-07-06 14:32:10 -06:00
parent e54ef44870
commit 1cad9fb5b6
2 changed files with 4 additions and 2 deletions
@@ -406,6 +406,7 @@ WOLFSSL_ESP_TASK tls_smp_server_task(void *args)
ESP_LOGI(TAG, "Done! Cleanup...");
/* Cleanup after this connection */
wolfSSL_free(ssl); /* Free the wolfSSL object */
ssl = NULL;
close(connd); /* Close the connection to the client */
#ifdef WOLFSSL_EXAMPLE_VERBOSITY
ESP_LOGI(TAG, "Stack used: %d\n",
+3 -2
View File
@@ -246,7 +246,7 @@ static int TLS_ECDH_callback(WOLFSSL* ssl, struct ecc_key* otherKey,
int main()
{
int sockfd;
int connd = 0;
int connd = -1;
struct sockaddr_in servAddr;
struct sockaddr_in clientAddr;
socklen_t size = sizeof(clientAddr);
@@ -379,7 +379,8 @@ int main()
end:
/* Cleanup after this connection */
wolfSSL_free(ssl); /* Free the wolfSSL object */
close(connd); /* Close the connection to the client */
if (connd != -1)
close(connd); /* Close the connection to the client */
wc_ecc_free(&blackKey);
printf("Shutdown complete\n");