diff options
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/by_dir.c | 4 | ||||
-rw-r--r-- | crypto/x509/x509_lu.c | 21 | ||||
-rw-r--r-- | crypto/x509/x509_vfy.c | 4 | ||||
-rw-r--r-- | crypto/x509/x509_vpm.c | 8 | ||||
-rw-r--r-- | crypto/x509/x509spki.c | 2 | ||||
-rw-r--r-- | crypto/x509/x_crl.c | 6 | ||||
-rw-r--r-- | crypto/x509/x_name.c | 6 |
7 files changed, 28 insertions, 23 deletions
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 3dd04d04aa..8310bc4701 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -229,12 +229,12 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) } } ent = OPENSSL_malloc(sizeof(*ent)); - if (!ent) + if (ent == NULL) return 0; ent->dir_type = type; ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp); ent->dir = OPENSSL_malloc((unsigned int)len + 1); - if (!ent->dir || !ent->hashes) { + if (ent->dir == NULL || ent->hashes == NULL) { by_dir_entry_free(ent); return 0; } diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 2bcac35eed..b61d757d3c 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -183,21 +183,26 @@ X509_STORE *X509_STORE_new(void) if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) return NULL; - ret->objs = sk_X509_OBJECT_new(x509_object_cmp); + if ((ret->objs = sk_X509_OBJECT_new(x509_object_cmp)) == NULL) + goto err; ret->cache = 1; - ret->get_cert_methods = sk_X509_LOOKUP_new_null(); + if ((ret->get_cert_methods = sk_X509_LOOKUP_new_null()) == NULL) + goto err; if ((ret->param = X509_VERIFY_PARAM_new()) == NULL) - return NULL; + goto err; - if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) { - sk_X509_OBJECT_free(ret->objs); - OPENSSL_free(ret); - return NULL; - } + if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) + goto err; ret->references = 1; return ret; +err: + X509_VERIFY_PARAM_free(ret->param); + sk_X509_OBJECT_free(ret->objs); + sk_X509_LOOKUP_free(ret->get_cert_methods); + OPENSSL_free(ret); + return NULL; } static void cleanup(X509_OBJECT *a) diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 1ae3675e2e..051751f7b3 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -2049,7 +2049,7 @@ X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, } /* Create new CRL */ crl = X509_CRL_new(); - if (!crl || !X509_CRL_set_version(crl, 1)) + if (crl == NULL || !X509_CRL_set_version(crl, 1)) goto memerr; /* Set issuer name */ if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer))) @@ -2267,7 +2267,7 @@ X509_STORE_CTX *X509_STORE_CTX_new(void) { X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); - if (!ctx) { + if (ctx == NULL) { X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c index cf8784d5fb..ceb79e2844 100644 --- a/crypto/x509/x509_vpm.c +++ b/crypto/x509/x509_vpm.c @@ -163,10 +163,10 @@ X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void) X509_VERIFY_PARAM_ID *paramid; param = OPENSSL_zalloc(sizeof(*param)); - if (!param) + if (param == NULL) return NULL; param->id = paramid = OPENSSL_zalloc(sizeof(*paramid)); - if (!paramid) { + if (paramid == NULL) { OPENSSL_free(param); return NULL; } @@ -580,9 +580,9 @@ int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) { int idx; X509_VERIFY_PARAM *ptmp; - if (!param_table) { + if (param_table == NULL) { param_table = sk_X509_VERIFY_PARAM_new(param_cmp); - if (!param_table) + if (param_table == NULL) return 0; } else { idx = sk_X509_VERIFY_PARAM_find(param_table, param); diff --git a/crypto/x509/x509spki.c b/crypto/x509/x509spki.c index 116f78800f..df27bf338a 100644 --- a/crypto/x509/x509spki.c +++ b/crypto/x509/x509spki.c @@ -111,7 +111,7 @@ char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki) der_len = i2d_NETSCAPE_SPKI(spki, NULL); der_spki = OPENSSL_malloc(der_len); b64_str = OPENSSL_malloc(der_len * 2); - if (!der_spki || !b64_str) { + if (der_spki == NULL || b64_str == NULL) { X509err(X509_F_NETSCAPE_SPKI_B64_ENCODE, ERR_R_MALLOC_FAILURE); OPENSSL_free(der_spki); OPENSSL_free(b64_str); diff --git a/crypto/x509/x_crl.c b/crypto/x509/x_crl.c index 79fa5ca34f..435de80810 100644 --- a/crypto/x509/x_crl.c +++ b/crypto/x509/x_crl.c @@ -357,9 +357,9 @@ int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev) { X509_CRL_INFO *inf; inf = &crl->crl; - if (!inf->revoked) + if (inf->revoked == NULL) inf->revoked = sk_X509_REVOKED_new(X509_REVOKED_cmp); - if (!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev)) { + if (inf->revoked == NULL || !sk_X509_REVOKED_push(inf->revoked, rev)) { ASN1err(ASN1_F_X509_CRL_ADD0_REVOKED, ERR_R_MALLOC_FAILURE); return 0; } @@ -478,7 +478,7 @@ X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl), { X509_CRL_METHOD *m; m = OPENSSL_malloc(sizeof(*m)); - if (!m) + if (m == NULL) return NULL; m->crl_init = crl_init; m->crl_free = crl_free; diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c index f52b91f06f..2895734cc1 100644 --- a/crypto/x509/x_name.c +++ b/crypto/x509/x_name.c @@ -135,7 +135,7 @@ static int x509_name_ex_new(ASN1_VALUE **val, const ASN1_ITEM *it) { X509_NAME *ret = OPENSSL_zalloc(sizeof(*ret)); - if (!ret) + if (ret == NULL) goto memerr; if ((ret->entries = sk_X509_NAME_ENTRY_new_null()) == NULL) goto memerr; @@ -361,7 +361,7 @@ static int x509_name_canon(X509_NAME *a) set = entry->set; } tmpentry = X509_NAME_ENTRY_new(); - if (!tmpentry) + if (tmpentry == NULL) goto err; tmpentry->object = OBJ_dup(entry->object); if (!asn1_string_canon(tmpentry->value, entry->value)) @@ -377,7 +377,7 @@ static int x509_name_canon(X509_NAME *a) p = OPENSSL_malloc(a->canon_enclen); - if (!p) + if (p == NULL) goto err; a->canon_enc = p; |