From d66c0e33810c9377ce1685a04919c1a835d8ad4b Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 20 Feb 2018 22:12:11 +0100 Subject: [PATCH] altcp: mbedtls: move freeing state->rx from close to dealloc (catch-all) --- src/apps/altcp_tls/altcp_tls_mbedtls.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/altcp_tls/altcp_tls_mbedtls.c b/src/apps/altcp_tls/altcp_tls_mbedtls.c index 71db44a1..9493195c 100644 --- a/src/apps/altcp_tls/altcp_tls_mbedtls.c +++ b/src/apps/altcp_tls/altcp_tls_mbedtls.c @@ -903,11 +903,6 @@ altcp_mbedtls_close(struct altcp_pcb *conn) } state = (altcp_mbedtls_state_t *)conn->state; if (state != NULL) { - if (state->rx) { - /* free leftover (unhandled) rx pbufs */ - pbuf_free(state->rx); - state->rx = NULL; - } state->flags |= ALTCP_MBEDTLS_FLAGS_TX_CLOSED; if (state->flags & ALTCP_MBEDTLS_FLAGS_RX_CLOSED) { altcp_mbedtls_dealloc(conn); @@ -1069,6 +1064,11 @@ altcp_mbedtls_dealloc(struct altcp_pcb *conn) if (state) { mbedtls_ssl_free(&state->ssl_context); state->flags = 0; + if (state->rx) { + /* free leftover (unhandled) rx pbufs */ + pbuf_free(state->rx); + state->rx = NULL; + } altcp_mbedtls_free(state->conf, state); conn->state = NULL; }