From 4084255fd5dba8778f8a235a2278f577193975ff Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 2 Nov 2017 09:48:12 -0700 Subject: [PATCH] Improve SSL failure cleanup case where ssl->ctx isn't set yet. --- src/internal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal.c b/src/internal.c index 22067077a..ae569af45 100644 --- a/src/internal.c +++ b/src/internal.c @@ -4845,6 +4845,7 @@ void SSL_ResourceFree(WOLFSSL* ssl) #endif WOLFSSL_HEAP_HINT* ssl_hint = (WOLFSSL_HEAP_HINT*)ssl->heap; WOLFSSL_HEAP* ctx_heap; + void* heap = ssl->ctx ? ssl->ctx->heap : ssl->heap; ctx_heap = ssl_hint->memory; if (wc_LockMutex(&(ctx_heap->memory_mutex)) != 0) { @@ -4864,10 +4865,9 @@ void SSL_ResourceFree(WOLFSSL* ssl) /* check if tracking stats */ if (ctx_heap->flag & WOLFMEM_TRACK_STATS) { - XFREE(ssl_hint->stats, ssl->ctx ? ssl->ctx->heap : NULL, - DYNAMIC_TYPE_SSL); + XFREE(ssl_hint->stats, heap, DYNAMIC_TYPE_SSL); } - XFREE(ssl->heap, ssl->ctx ? ssl->ctx->heap : NULL, DYNAMIC_TYPE_SSL); + XFREE(ssl->heap, heap, DYNAMIC_TYPE_SSL); #ifdef WOLFSSL_HEAP_TEST } #endif