Commit 323e48b6fb for openssl.org
commit 323e48b6fbfe5f7cf6c49aab20478ef95387bbf1
Author: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Date: Fri Jun 27 18:38:19 2025 +0000
demos/bio/sconnect.c: Add check for BIO_new()
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)
diff --git a/demos/bio/sconnect.c b/demos/bio/sconnect.c
index 7cdfa401f4..e069209e72 100644
--- a/demos/bio/sconnect.c
+++ b/demos/bio/sconnect.c
@@ -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 [] */