Skip to content

Commit e242f3d

Browse files
chipitsinewtarreau
authored andcommitted
BUG/MINOR: ssl_sock: Fix memory leak when disabling compression
according to manpage: sk_TYPE_zero() sets the number of elements in sk to zero. It does not free sk so after this call sk is still valid. so we need to free all elements [wt: seems like it has been there forever and should be backported to all stable branches]
1 parent 4438c60 commit e242f3d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ssl_sock.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9702,6 +9702,7 @@ __attribute__((constructor))
97029702
static void __ssl_sock_init(void)
97039703
{
97049704
STACK_OF(SSL_COMP)* cm;
9705+
int n;
97059706

97069707
if (global_ssl.listen_default_ciphers)
97079708
global_ssl.listen_default_ciphers = strdup(global_ssl.listen_default_ciphers);
@@ -9719,7 +9720,11 @@ static void __ssl_sock_init(void)
97199720
SSL_library_init();
97209721
#endif
97219722
cm = SSL_COMP_get_compression_methods();
9722-
sk_SSL_COMP_zero(cm);
9723+
n = sk_SSL_COMP_num(cm);
9724+
while (n--) {
9725+
(void) sk_SSL_COMP_pop(cm);
9726+
}
9727+
97239728
#if defined(USE_THREAD) && (HA_OPENSSL_VERSION_NUMBER < 0x10100000L)
97249729
ssl_locking_init();
97259730
#endif

0 commit comments

Comments
 (0)