From 8c870f6bed241ec80c67453e60592461f0d8f2b8 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 13 Jan 2022 12:30:59 +1100 Subject: coverity 1497107: dereference after null check Add null checks to avoid dereferencing a pointer that could be null. Reviewed-by: Tim Hudson Reviewed-by: Tomas Mraz Reviewed-by: David von Oheimb (Merged from https://github.com/openssl/openssl/pull/17488) --- apps/lib/apps.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 7ca30ef590..77edc1d936 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -691,10 +691,13 @@ int load_cert_certs(const char *uri, if (ret) { if (pcert != NULL) warn_cert(uri, *pcert, 0, vpm); - warn_certs(uri, *pcerts, 1, vpm); + if (pcerts != NULL) + warn_certs(uri, *pcerts, 1, vpm); } else { - OSSL_STACK_OF_X509_free(*pcerts); - *pcerts = NULL; + if (pcerts != NULL) { + OSSL_STACK_OF_X509_free(*pcerts); + *pcerts = NULL; + } } return ret; } -- cgit v1.2.3