mirror of
https://github.com/openssl/openssl.git
synced 2025-03-25 20:00:44 +08:00
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>
This commit is contained in:
parent
4500a4cd4d
commit
43ecb9c35c
@ -75,7 +75,8 @@
|
||||
|
||||
BIO_ADDR *BIO_ADDR_new(void)
|
||||
{
|
||||
BIO_ADDR *ret = (BIO_ADDR *)OPENSSL_zalloc(sizeof(BIO_ADDR));
|
||||
BIO_ADDR *ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
|
||||
ret->sa.sa_family = AF_UNSPEC;
|
||||
return ret;
|
||||
}
|
||||
@ -557,10 +558,10 @@ static int addrinfo_wrap(int family, int socktype,
|
||||
{
|
||||
OPENSSL_assert(bai != NULL);
|
||||
|
||||
*bai = (BIO_ADDRINFO *)OPENSSL_zalloc(sizeof(**bai));
|
||||
|
||||
*bai = OPENSSL_zalloc(sizeof(**bai));
|
||||
if (*bai == NULL)
|
||||
return 0;
|
||||
|
||||
(*bai)->bai_family = family;
|
||||
(*bai)->bai_socktype = socktype;
|
||||
if (socktype == SOCK_STREAM)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -171,12 +171,14 @@ size_t HMAC_size(HMAC_CTX *ctx)
|
||||
|
||||
HMAC_CTX *HMAC_CTX_new(void)
|
||||
{
|
||||
HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
|
||||
if (ctx)
|
||||
HMAC_CTX *ctx = OPENSSL_zalloc(sizeof(HMAC_CTX));
|
||||
|
||||
if (ctx != NULL) {
|
||||
if (!HMAC_CTX_reset(ctx)) {
|
||||
HMAC_CTX_free(ctx);
|
||||
ctx = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user