diff options
author | Rich Salz <rsalz@openssl.org> | 2016-02-08 10:11:56 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-02-08 11:09:16 -0500 |
commit | 43ecb9c35caed8623cfd83e7d893b8b67725feb7 (patch) | |
tree | 676696126afa484d7afeba51771fdc8d41cc04ab /crypto/evp | |
parent | 4500a4cd4d89ba338ad796d39ccb9d94794cc0d7 (diff) | |
download | openssl-43ecb9c35caed8623cfd83e7d893b8b67725feb7.tar.gz |
GH641: Don't care openssl_zmalloc
Don't cast malloc-family return values.
Also found some places where (a) blank line was missing; and (b)
the *wrong* return value was checked.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/evp')
-rw-r--r-- | crypto/evp/cmeth_lib.c | 6 | ||||
-rw-r--r-- | crypto/evp/encode.c | 2 | ||||
-rw-r--r-- | crypto/evp/evp_lib.c | 6 |
3 files changed, 9 insertions, 5 deletions
diff --git a/crypto/evp/cmeth_lib.c b/crypto/evp/cmeth_lib.c index 1e7cac8157..33944e1894 100644 --- a/crypto/evp/cmeth_lib.c +++ b/crypto/evp/cmeth_lib.c @@ -64,7 +64,8 @@ EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len) { - EVP_CIPHER *cipher = (EVP_CIPHER *)OPENSSL_zalloc(sizeof(EVP_CIPHER)); + EVP_CIPHER *cipher = OPENSSL_zalloc(sizeof(EVP_CIPHER)); + if (cipher != NULL) { cipher->nid = cipher_type; cipher->block_size = block_size; @@ -77,7 +78,8 @@ EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher) { EVP_CIPHER *to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size, cipher->key_len); - if (cipher != NULL) + + if (to != NULL) memcpy(to, cipher, sizeof(*to)); return to; } diff --git a/crypto/evp/encode.c b/crypto/evp/encode.c index de52ae4c2f..ed85f8933b 100644 --- a/crypto/evp/encode.c +++ b/crypto/evp/encode.c @@ -142,7 +142,7 @@ static unsigned char conv_ascii2bin(unsigned char a) EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void) { - return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX)); + return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX)); } void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx) diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index ff2a1d253a..a1636284c0 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -352,7 +352,8 @@ unsigned long EVP_MD_flags(const EVP_MD *md) EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type) { - EVP_MD *md = (EVP_MD *)OPENSSL_zalloc(sizeof(EVP_MD)); + EVP_MD *md = OPENSSL_zalloc(sizeof(*md)); + if (md != NULL) { md->type = md_type; md->pkey_type = pkey_type; @@ -362,7 +363,8 @@ EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type) EVP_MD *EVP_MD_meth_dup(const EVP_MD *md) { EVP_MD *to = EVP_MD_meth_new(md->type, md->pkey_type); - if (md != NULL) + + if (to != NULL) memcpy(to, md, sizeof(*to)); return to; } |