From: Willy Tarreau Date: Fri, 26 Feb 2021 20:05:08 +0000 (+0100) Subject: CLEANUP: ssl: use realloc() instead of free()+malloc() X-Git-Tag: v2.4-dev10~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3bda3f422ee8c3da6b807c6e37db0b3d934ef740;p=thirdparty%2Fhaproxy.git CLEANUP: ssl: use realloc() instead of free()+malloc() There was a free(ptr) followed by ptr=malloc(ptr, len), which is the equivalent of ptr = realloc(ptr, len) but slower and less clean. Let's replace this. --- diff --git a/src/ssl_sock.c b/src/ssl_sock.c index b10281a00d..2abd6661e8 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -3996,8 +3996,8 @@ static int ssl_sess_new_srv_cb(SSL *ssl, SSL_SESSION *sess) if (s->ssl_ctx.reused_sess[tid].ptr && s->ssl_ctx.reused_sess[tid].allocated_size >= len) { ptr = s->ssl_ctx.reused_sess[tid].ptr; } else { - free(s->ssl_ctx.reused_sess[tid].ptr); - ptr = s->ssl_ctx.reused_sess[tid].ptr = malloc(len); + ptr = realloc(s->ssl_ctx.reused_sess[tid].ptr, len); + s->ssl_ctx.reused_sess[tid].ptr = ptr; s->ssl_ctx.reused_sess[tid].allocated_size = len; } if (s->ssl_ctx.reused_sess[tid].ptr) {