From fb03e6145961005a6db011d2f36660d2eed734e2 Mon Sep 17 00:00:00 2001 From: xkernel Date: Thu, 20 Oct 2022 00:40:25 +0800 Subject: Checking the return of BIO_new_fp(). If it returns NULL, then it is unnecessary to build the BIO chain and better make the caller directly return NULL Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/19445) --- apps/lib/apps.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/lib/apps.c b/apps/lib/apps.c index b51afba898..3d52e030ab 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -2972,6 +2972,9 @@ BIO *dup_bio_out(int format) BIO_NOCLOSE | (FMT_istext(format) ? BIO_FP_TEXT : 0)); void *prefix = NULL; + if (b == NULL) + return NULL; + #ifdef OPENSSL_SYS_VMS if (FMT_istext(format)) b = BIO_push(BIO_new(BIO_f_linebuffer()), b); @@ -2992,7 +2995,7 @@ BIO *dup_bio_err(int format) BIO_NOCLOSE | (FMT_istext(format) ? BIO_FP_TEXT : 0)); #ifdef OPENSSL_SYS_VMS - if (FMT_istext(format)) + if (b != NULL && FMT_istext(format)) b = BIO_push(BIO_new(BIO_f_linebuffer()), b); #endif return b; -- cgit v1.2.3