From bb8853aa50f186127b364d6337e249d69e5945e7 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 30 Oct 2014 16:23:25 -0700 Subject: [PATCH] fix memory leak when resetting the peer address on a DTLS session --- src/ssl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ssl.c b/src/ssl.c index e7d12d75e..425ca74e7 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -293,6 +293,8 @@ int CyaSSL_dtls_set_peer(CYASSL* ssl, void* peer, unsigned int peerSz) #ifdef CYASSL_DTLS void* sa = (void*)XMALLOC(peerSz, ssl->heap, DYNAMIC_TYPE_SOCKADDR); if (sa != NULL) { + if (ssl->buffers.dtlsCtx.peer.sa != NULL) + XFREE(ssl->buffers.dtlsCtx.peer.sa,ssl->heap,DYNAMIC_TYPE_SOCKADDR); XMEMCPY(sa, peer, peerSz); ssl->buffers.dtlsCtx.peer.sa = sa; ssl->buffers.dtlsCtx.peer.sz = peerSz;