From: Angus Gratton Date: Thu, 19 Apr 2018 01:34:06 +0000 (+1000) Subject: esp-tls: Allow esp_tls_conn_delete() to be called with a NULL pointer X-Git-Tag: v3.1-beta1~227^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=507ca8196ca3b88717aaa7dc2fa3bd54193548da;p=esp-idf esp-tls: Allow esp_tls_conn_delete() to be called with a NULL pointer --- diff --git a/components/esp-tls/esp_tls.c b/components/esp-tls/esp_tls.c index 5309d7796a..73130a64df 100644 --- a/components/esp-tls/esp_tls.c +++ b/components/esp-tls/esp_tls.c @@ -230,11 +230,13 @@ exit: */ void esp_tls_conn_delete(esp_tls_t *tls) { - mbedtls_cleanup(tls); - if (tls->sockfd) { - close(tls->sockfd); + if (tls != NULL) { + mbedtls_cleanup(tls); + if (tls->sockfd) { + close(tls->sockfd); + } + free(tls); } - free(tls); }; static ssize_t tcp_write(esp_tls_t *tls, const char *data, size_t datalen)