Skip to content

Commit

Permalink
Check memory allocation
Browse files Browse the repository at this point in the history
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
  • Loading branch information
ghedo authored and levitte committed Oct 23, 2015
1 parent 3240e7c commit 8cf9d71
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crypto/evp/evp_pbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
{
EVP_PBE_CTL *pbe_tmp;

if (pbe_algs == NULL)
if (pbe_algs == NULL) {
pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) {
EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
return 0;
if (pbe_algs == NULL)
goto err;
}

if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL)
goto err;

pbe_tmp->pbe_type = pbe_type;
pbe_tmp->pbe_nid = pbe_nid;
pbe_tmp->cipher_nid = cipher_nid;
Expand All @@ -223,6 +226,10 @@ int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,

sk_EVP_PBE_CTL_push(pbe_algs, pbe_tmp);
return 1;

err:
EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
return 0;
}

int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
Expand Down

0 comments on commit 8cf9d71

Please sign in to comment.