Commit 07cd5562d2 for openssl.org

commit 07cd5562d245462c4ddf78becfb0401dd3a4c99d
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date:   Fri May 8 16:41:08 2026 +0200

    Fix BIO dgram pair memleak in dgram_mem_init

    The created pair was not freed if ring buf init failed.

    Fixes: 3a857b953216 "Implement BIO_s_dgram_mem() reusing the BIO_s_dgram_pair() code"

    Reviewed-by: Matt Caswell <matt@openssl.foundation>
    Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    MergeDate: Mon May 11 08:09:14 2026
    (Merged from https://github.com/openssl/openssl/pull/31121)

diff --git a/crypto/bio/bss_dgram_pair.c b/crypto/bio/bss_dgram_pair.c
index bd9b7b892c..d0136b4afc 100644
--- a/crypto/bio/bss_dgram_pair.c
+++ b/crypto/bio/bss_dgram_pair.c
@@ -305,6 +305,7 @@ static int dgram_mem_init(BIO *bio)
     b = bio->ptr;

     if (ring_buf_init(&b->rbuf, b->req_buf_len) == 0) {
+        dgram_pair_free(bio);
         ERR_raise(ERR_LIB_BIO, ERR_R_BIO_LIB);
         return 0;
     }