From c7a392d351feb64e9032aa9fe43a5e582736df7e Mon Sep 17 00:00:00 2001 From: John Safranek Date: Tue, 26 Jan 2021 17:36:15 -0800 Subject: [PATCH] if a handshake info has a stored kex init message already before trying to store a kex init message, free it --- src/internal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/internal.c b/src/internal.c index 0e67975..4bc7d6a 100644 --- a/src/internal.c +++ b/src/internal.c @@ -6352,6 +6352,12 @@ int SendKexInit(WOLFSSH* ssh) ssh->outputBuffer.length = idx; + if (ssh->handshake->kexInit != NULL) { + WFREE(ssh->handshake->kexInit, ssh->ctx->heap, DYNTYPE_STRING); + ssh->handshake->kexInit = NULL; + ssh->handshake->kexInitSz = 0; + } + buf = (byte*)WMALLOC(bufSz, ssh->ctx->heap, DYNTYPE_STRING); if (buf == NULL) { WLOG(WS_LOG_DEBUG, "Cannot allocate storage for KEX Init msg");