summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-02-08 22:20:19 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-02-08 22:20:19 +0000
commit976a1deebc7fa367cb71d2a76816113d09721323 (patch)
tree411044cd1d88b29122fad411310e997fa8824c2e /lib/libcrypto
parent221e06d9370d564be7821c26acb68300d76052b5 (diff)
Check memory allocation results in EVP_PBE_alg_add_type().
ok doug@ jsing@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/evp/evp_pbe.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libcrypto/evp/evp_pbe.c b/lib/libcrypto/evp/evp_pbe.c
index ac593549e5d..0787e2dc942 100644
--- a/lib/libcrypto/evp/evp_pbe.c
+++ b/lib/libcrypto/evp/evp_pbe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp_pbe.c,v 1.22 2014/10/28 05:46:56 miod Exp $ */
+/* $OpenBSD: evp_pbe.c,v 1.23 2015/02/08 22:20:18 miod Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
*/
@@ -203,9 +203,16 @@ EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
{
EVP_PBE_CTL *pbe_tmp;
- if (!pbe_algs)
+ if (pbe_algs == NULL) {
pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
- if (!(pbe_tmp = (EVP_PBE_CTL*)malloc(sizeof(EVP_PBE_CTL)))) {
+ if (pbe_algs == NULL) {
+ EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE,
+ ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+ }
+ pbe_tmp = malloc(sizeof(EVP_PBE_CTL));
+ if (pbe_tmp == NULL) {
EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
return 0;
}