Fix double-free when closing mbedTLS connections

Partly revert commit 0486100a2b from 07.08.2017 as it breaks layering: every layer must free its own altcp_pcb. Freeing the inner_conn is not the right way.
This commit is contained in:
goldsimon 2017-11-14 22:21:08 +01:00
parent 6ef5f68c72
commit bd2e820829

View File

@ -563,6 +563,8 @@ altcp_mbedtls_setup(void *conf, struct altcp_pcb *conn, struct altcp_pcb *inner_
if (!conf) { if (!conf) {
return ERR_ARG; return ERR_ARG;
} }
LWIP_ASSERT("invalid inner_conn", conn != inner_conn);
/* allocate mbedtls context */ /* allocate mbedtls context */
state = altcp_mbedtls_alloc(conf); state = altcp_mbedtls_alloc(conf);
if (state == NULL) { if (state == NULL) {
@ -970,10 +972,6 @@ altcp_mbedtls_dealloc(struct altcp_pcb *conn)
altcp_mbedtls_free(state->conf, state); altcp_mbedtls_free(state->conf, state);
conn->state = NULL; conn->state = NULL;
} }
if (conn->inner_conn) {
altcp_free(conn->inner_conn);
conn->inner_conn = NULL;
}
} }
} }