diff options
author | 2015-07-15 16:53:42 +0000 | |
---|---|---|
committer | 2015-07-15 16:53:42 +0000 | |
commit | 6409ae5f02cadef82f6cead768c9c5fb89df4c2c (patch) | |
tree | 9bc1aa79b94ad755d6ac41ef9beb6756b17a26a4 /lib/libssl/src | |
parent | Do not allow TS_check_signer_name() with signer == NULL from (diff) | |
download | wireguard-openbsd-6409ae5f02cadef82f6cead768c9c5fb89df4c2c.tar.xz wireguard-openbsd-6409ae5f02cadef82f6cead768c9c5fb89df4c2c.zip |
Avoid leaking objects upon error; tweaks & ok doug@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r-- | lib/libssl/src/crypto/x509v3/pcy_data.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/libssl/src/crypto/x509v3/pcy_data.c b/lib/libssl/src/crypto/x509v3/pcy_data.c index 698ca6ace57..b3699b02807 100644 --- a/lib/libssl/src/crypto/x509v3/pcy_data.c +++ b/lib/libssl/src/crypto/x509v3/pcy_data.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcy_data.c,v 1.8 2014/07/11 08:44:49 jsing Exp $ */ +/* $OpenBSD: pcy_data.c,v 1.9 2015/07/15 16:53:42 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -85,45 +85,45 @@ policy_data_free(X509_POLICY_DATA *data) X509_POLICY_DATA * policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *cid, int crit) { - X509_POLICY_DATA *ret; - ASN1_OBJECT *id; + X509_POLICY_DATA *ret = NULL; + ASN1_OBJECT *id = NULL; - if (!policy && !cid) + if (policy == NULL && cid == NULL) return NULL; - if (cid) { + if (cid != NULL) { id = OBJ_dup(cid); - if (!id) + if (id == NULL) return NULL; - } else - id = NULL; + } ret = malloc(sizeof(X509_POLICY_DATA)); - if (!ret) - return NULL; + if (ret == NULL) + goto err; ret->expected_policy_set = sk_ASN1_OBJECT_new_null(); - if (!ret->expected_policy_set) { - free(ret); - if (id) - ASN1_OBJECT_free(id); - return NULL; - } + if (ret->expected_policy_set == NULL) + goto err; if (crit) ret->flags = POLICY_DATA_FLAG_CRITICAL; else ret->flags = 0; - if (id) + if (id != NULL) ret->valid_policy = id; else { ret->valid_policy = policy->policyid; policy->policyid = NULL; } - if (policy) { + if (policy != NULL) { ret->qualifier_set = policy->qualifiers; policy->qualifiers = NULL; } else ret->qualifier_set = NULL; return ret; + +err: + free(ret); + ASN1_OBJECT_free(id); + return NULL; } |