summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLoganaden Velvindron <logan@cvs.openbsd.org>2014-06-28 18:14:58 +0000
committerLoganaden Velvindron <logan@cvs.openbsd.org>2014-06-28 18:14:58 +0000
commit4d40a005624d12359560221614032971f788d8e2 (patch)
treef431e468b2306188d2e255331a13e54362805a76 /lib
parentf586e998bd50f6ef192c67a75ce56f6fc0c8e1da (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.c11
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;