diff options
author | Rich Salz <rsalz@akamai.com> | 2015-09-03 09:15:26 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-09-03 16:26:34 -0400 |
commit | 64b25758edca688a30f02c260262150f7ad0bc7d (patch) | |
tree | 15ad5a8c7985e2b27aaf7a14737fd980a36349dd /crypto/asn1 | |
parent | fb4844bbc62fb014c115cd8fd2fc4304cba6eb89 (diff) |
remove 0 assignments.
After openssl_zalloc, cleanup more "set to 0/NULL" assignments.
Many are from github feedback.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_object.c | 7 | ||||
-rw-r--r-- | crypto/asn1/ameth_lib.c | 35 | ||||
-rw-r--r-- | crypto/asn1/asn1_lib.c | 5 | ||||
-rw-r--r-- | crypto/asn1/tasn_prn.c | 8 | ||||
-rw-r--r-- | crypto/asn1/x_info.c | 12 | ||||
-rw-r--r-- | crypto/asn1/x_pkey.c | 7 |
6 files changed, 8 insertions, 66 deletions
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index ab37fa315f..44473dc1b3 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -345,16 +345,11 @@ ASN1_OBJECT *ASN1_OBJECT_new(void) { ASN1_OBJECT *ret; - ret = OPENSSL_malloc(sizeof(*ret)); + ret = OPENSSL_zalloc(sizeof(*ret)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_OBJECT_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } - ret->length = 0; - ret->data = NULL; - ret->nid = 0; - ret->sn = NULL; - ret->ln = NULL; ret->flags = ASN1_OBJECT_FLAG_DYNAMIC; return (ret); } diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index 155de83aaa..feef015acc 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -296,48 +296,17 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, ameth->info = BUF_strdup(info); if (!ameth->info) goto err; - } else - ameth->info = NULL; + } if (pem_str) { ameth->pem_str = BUF_strdup(pem_str); if (!ameth->pem_str) goto err; - } else - ameth->pem_str = NULL; - - ameth->pub_decode = 0; - ameth->pub_encode = 0; - ameth->pub_cmp = 0; - ameth->pub_print = 0; - - ameth->priv_decode = 0; - ameth->priv_encode = 0; - ameth->priv_print = 0; - - ameth->old_priv_encode = 0; - ameth->old_priv_decode = 0; - - ameth->item_verify = 0; - ameth->item_sign = 0; - - ameth->pkey_size = 0; - ameth->pkey_bits = 0; - - ameth->param_decode = 0; - ameth->param_encode = 0; - ameth->param_missing = 0; - ameth->param_copy = 0; - ameth->param_cmp = 0; - ameth->param_print = 0; - - ameth->pkey_free = 0; - ameth->pkey_ctrl = 0; + } return ameth; err: - EVP_PKEY_asn1_free(ameth); return NULL; diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c index 94b5ad5d91..3b366449a9 100644 --- a/crypto/asn1/asn1_lib.c +++ b/crypto/asn1/asn1_lib.c @@ -348,15 +348,12 @@ ASN1_STRING *ASN1_STRING_type_new(int type) { ASN1_STRING *ret; - ret = OPENSSL_malloc(sizeof(*ret)); + ret = OPENSSL_zalloc(sizeof(*ret)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } - ret->length = 0; ret->type = type; - ret->data = NULL; - ret->flags = 0; return (ret); } diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index 716db8f7c2..5314c61b24 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -85,16 +85,12 @@ ASN1_PCTX default_pctx = { ASN1_PCTX *ASN1_PCTX_new(void) { ASN1_PCTX *ret; - ret = OPENSSL_malloc(sizeof(*ret)); + + ret = OPENSSL_zalloc(sizeof(*ret)); if (ret == NULL) { ASN1err(ASN1_F_ASN1_PCTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } - ret->flags = 0; - ret->nm_flags = 0; - ret->cert_flags = 0; - ret->oid_flags = 0; - ret->str_flags = 0; return ret; } diff --git a/crypto/asn1/x_info.c b/crypto/asn1/x_info.c index 5be934c690..0a75e49361 100644 --- a/crypto/asn1/x_info.c +++ b/crypto/asn1/x_info.c @@ -64,22 +64,14 @@ X509_INFO *X509_INFO_new(void) { - X509_INFO *ret = NULL; + X509_INFO *ret; - ret = OPENSSL_malloc(sizeof(*ret)); + ret = OPENSSL_zalloc(sizeof(*ret)); if (ret == NULL) { ASN1err(ASN1_F_X509_INFO_NEW, ERR_R_MALLOC_FAILURE); return (NULL); } - - ret->enc_cipher.cipher = NULL; - ret->enc_len = 0; - ret->enc_data = NULL; - ret->references = 1; - ret->x509 = NULL; - ret->crl = NULL; - ret->x_pkey = NULL; return (ret); } diff --git a/crypto/asn1/x_pkey.c b/crypto/asn1/x_pkey.c index 0710419596..0665aab622 100644 --- a/crypto/asn1/x_pkey.c +++ b/crypto/asn1/x_pkey.c @@ -70,17 +70,10 @@ X509_PKEY *X509_PKEY_new(void) if (!ret) goto err; - ret->version = 0; ret->enc_algor = X509_ALGOR_new(); ret->enc_pkey = ASN1_OCTET_STRING_new(); if (!ret->enc_algor || !ret->enc_pkey) goto err; - ret->dec_pkey = NULL; - ret->key_length = 0; - ret->key_data = NULL; - ret->key_free = 0; - ret->cipher.cipher = NULL; - memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH); ret->references = 1; return ret; err: |