From: Jiasheng Jiang Date: Fri, 27 Jun 2025 18:38:19 +0000 (+0000) Subject: demos/bio/sconnect.c: Add check for BIO_new() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=323e48b6fbfe5f7cf6c49aab20478ef95387bbf1;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Dmitry Belyavskiy Reviewed-by: Frederik Wedel-Heinen Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/27919) --- diff --git a/demos/bio/sconnect.c b/demos/bio/sconnect.c index 7cdfa401f41..e069209e726 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 [] */