diff options
author | Loganaden Velvindron <logan@cvs.openbsd.org> | 2014-06-28 18:14:58 +0000 |
---|---|---|
committer | Loganaden Velvindron <logan@cvs.openbsd.org> | 2014-06-28 18:14:58 +0000 |
commit | 4d40a005624d12359560221614032971f788d8e2 (patch) | |
tree | f431e468b2306188d2e255331a13e54362805a76 /lib | |
parent | f586e998bd50f6ef192c67a75ce56f6fc0c8e1da (diff) |
Fix 9 memory leaks.
(Thanks to Brent Cook)
With help from tedu@
OK from tedu@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/x509v3/v3_purp.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libcrypto/x509v3/v3_purp.c b/lib/libcrypto/x509v3/v3_purp.c index de41a51914a..67fb7baa3e2 100644 --- a/lib/libcrypto/x509v3/v3_purp.c +++ b/lib/libcrypto/x509v3/v3_purp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: v3_purp.c,v 1.17 2014/06/12 15:49:31 deraadt Exp $ */ +/* $OpenBSD: v3_purp.c,v 1.18 2014/06/28 18:14:57 logan Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -226,6 +226,9 @@ X509_PURPOSE_add(int id, int trust, int flags, ptmp->name = BUF_strdup(name); ptmp->sname = BUF_strdup(sname); if (!ptmp->name || !ptmp->sname) { + free(ptmp->name); + free(ptmp->sname); + free(ptmp); X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } @@ -242,11 +245,17 @@ X509_PURPOSE_add(int id, int trust, int flags, /* If its a new entry manage the dynamic table */ if (idx == -1) { if (!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) { + free(ptmp->name); + free(ptmp->sname); + free(ptmp); X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } if (!sk_X509_PURPOSE_push(xptable, ptmp)) { + free(ptmp->name); + free(ptmp->sname); + free(ptmp); X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; |