]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
demos/bio/sconnect.c: Add check for BIO_new() master
authorJiasheng Jiang <jiashengjiangcool@gmail.com>
Fri, 27 Jun 2025 18:38:19 +0000 (18:38 +0000)
committerNeil Horman <nhorman@openssl.org>
Sun, 28 Dec 2025 21:56:32 +0000 (16:56 -0500)
Add check for the return value of BIO_new() to guarantee the success.

Fixes: 0f113f3ee4 ("Run util/openssl-format-source -v -c .")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27919)

demos/bio/sconnect.c

index 7cdfa401f41fbe13035f99bf9745c15832c99f05..e069209e7261a58ec81aba60d5edc0cdc84a5db7 100644 (file)
@@ -65,10 +65,18 @@ int main(int argc, char *argv[])
 
     /* Use it inside an SSL BIO */
     ssl_bio = BIO_new(BIO_f_ssl());
+    if (ssl_bio == NULL)
+        goto err;
+
     BIO_set_ssl(ssl_bio, ssl, BIO_CLOSE);
 
     /* Lets use a connect BIO under the SSL BIO */
     out = BIO_new(BIO_s_connect());
+    if (out == NULL) {
+        BIO_free(ssl_bio);
+        goto err;
+    }
+
     BIO_set_conn_hostname(out, hostport);
 
     /* The BIO has parsed the host:port and even IPv6 literals in [] */