From 28051edf665bca7ebeed01e8415ac94eb4d12c5f Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 2 May 2017 04:11:08 +0000 Subject: [PATCH] the XXXfree functions being called accept NULL, so don't check first. ok beck --- lib/libcrypto/x509v3/v3_crld.c | 11 ++++------- lib/libcrypto/x509v3/v3_ncons.c | 9 +++------ lib/libcrypto/x509v3/v3_pci.c | 20 +++++++------------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/lib/libcrypto/x509v3/v3_crld.c b/lib/libcrypto/x509v3/v3_crld.c index f9f69fee145..8660c1ee4b4 100644 --- a/lib/libcrypto/x509v3/v3_crld.c +++ b/lib/libcrypto/x509v3/v3_crld.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_crld.c,v 1.21 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_crld.c,v 1.22 2017/05/02 04:11:08 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -186,10 +186,8 @@ set_dist_point_name(DIST_POINT_NAME **pdp, X509V3_CTX *ctx, CONF_VALUE *cnf) return 1; err: - if (fnm) - sk_GENERAL_NAME_pop_free(fnm, GENERAL_NAME_free); - if (rnm) - sk_X509_NAME_ENTRY_pop_free(rnm, X509_NAME_ENTRY_free); + sk_GENERAL_NAME_pop_free(fnm, GENERAL_NAME_free); + sk_X509_NAME_ENTRY_pop_free(rnm, X509_NAME_ENTRY_free); return -1; } @@ -300,8 +298,7 @@ crldp_from_section(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval) return point; err: - if (point) - DIST_POINT_free(point); + DIST_POINT_free(point); return NULL; } diff --git a/lib/libcrypto/x509v3/v3_ncons.c b/lib/libcrypto/x509v3/v3_ncons.c index 88643981caa..d22ca5e9cdf 100644 --- a/lib/libcrypto/x509v3/v3_ncons.c +++ b/lib/libcrypto/x509v3/v3_ncons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_ncons.c,v 1.11 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_ncons.c,v 1.12 2017/05/02 04:11:08 deraadt Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -223,11 +223,8 @@ v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, memerr: X509V3error(ERR_R_MALLOC_FAILURE); err: - if (ncons) - NAME_CONSTRAINTS_free(ncons); - if (sub) - GENERAL_SUBTREE_free(sub); - + NAME_CONSTRAINTS_free(ncons); + GENERAL_SUBTREE_free(sub); return NULL; } diff --git a/lib/libcrypto/x509v3/v3_pci.c b/lib/libcrypto/x509v3/v3_pci.c index dd015452d0f..437b3aee3df 100644 --- a/lib/libcrypto/x509v3/v3_pci.c +++ b/lib/libcrypto/x509v3/v3_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_pci.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: v3_pci.c,v 1.13 2017/05/02 04:11:08 deraadt Exp $ */ /* Contributed to the OpenSSL Project 2004 * by Richard Levitte (richard@levitte.org) */ @@ -298,18 +298,12 @@ r2i_pci(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value) goto end; err: - if (language) { - ASN1_OBJECT_free(language); - language = NULL; - } - if (pathlen) { - ASN1_INTEGER_free(pathlen); - pathlen = NULL; - } - if (policy) { - ASN1_OCTET_STRING_free(policy); - policy = NULL; - } + ASN1_OBJECT_free(language); + language = NULL; + ASN1_INTEGER_free(pathlen); + pathlen = NULL; + ASN1_OCTET_STRING_free(policy); + policy = NULL; end: sk_CONF_VALUE_pop_free(vals, X509V3_conf_free); return pci; -- 2.20.1