BUG/MINOR: ssl_sock: fix possible memory leak on OOM

That's the classical realloc() issue: if it returns NULL, the old area
is not freed but we erase the pointer. It was brought by commit e18d4e828
("BUG/MEDIUM: ssl: backend TLS resumption with sni and TLSv1.3"), and
should be backported where this commit was backported.
This commit is contained in:
Willy Tarreau 2023-08-21 08:45:35 +02:00
parent 7e9aea789f
commit ff9e653859

View File

@ -4280,6 +4280,8 @@ static int ssl_sess_new_srv_cb(SSL *ssl, SSL_SESSION *sess)
ptr = s->ssl_ctx.reused_sess[tid].ptr;
} else {
ptr = realloc(s->ssl_ctx.reused_sess[tid].ptr, len);
if (!ptr)
free(s->ssl_ctx.reused_sess[tid].ptr);
s->ssl_ctx.reused_sess[tid].ptr = ptr;
s->ssl_ctx.reused_sess[tid].allocated_size = len;
}