Commit 2b78d2c40d for openssl.org
commit 2b78d2c40d06dc1efd4d6f21824b6410c1a7019c
Author: 609bob <1850029304@qq.com>
Date: Wed Oct 28 20:56:49 2026 +0800
crypto/bio/bss_dgram_pair.c: fix memory leak in dgram_pair_ctrl_make_bio_pair()
Free pair->map[0].rbuf.start on ring_buf_init() of pair->map[1].rbuf,
and free both ring buffers on lock creation failure.
Fixes: f99bbcd5afff "Dont have dgram_pairs track bios, track bio_dgram_pair_st instead"
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Merge-date: Sun Nov 1 15:32:20 2026
Merged-from: https://github.com/openssl/openssl/pull/33436
diff --git a/crypto/bio/bss_dgram_pair.c b/crypto/bio/bss_dgram_pair.c
index 89f05da85b..d85e42604c 100644
--- a/crypto/bio/bss_dgram_pair.c
+++ b/crypto/bio/bss_dgram_pair.c
@@ -564,6 +564,7 @@ static int dgram_pair_ctrl_make_bio_pair(BIO *bio1, BIO *bio2)
if (ring_buf_init(&pair->map[1].rbuf, b2->req_buf_len) == 0) {
CRYPTO_FREE_REF(&pair->ref_cnt);
CRYPTO_THREAD_lock_free(pair->peerlock);
+ OPENSSL_free(pair->map[0].rbuf.start);
OPENSSL_free(pair);
ERR_raise(ERR_LIB_BIO, BIO_R_UNINITIALIZED);
return 0;
@@ -577,6 +578,8 @@ static int dgram_pair_ctrl_make_bio_pair(BIO *bio1, BIO *bio2)
CRYPTO_THREAD_lock_free(pair->map[1].lock);
CRYPTO_THREAD_lock_free(pair->peerlock);
CRYPTO_FREE_REF(&pair->ref_cnt);
+ OPENSSL_free(pair->map[0].rbuf.start);
+ OPENSSL_free(pair->map[1].rbuf.start);
OPENSSL_free(pair);
ERR_raise(ERR_LIB_BIO, BIO_R_UNINITIALIZED);
return 0;