summaryrefslogtreecommitdiff
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
commited547f971b60b797bbcec23016613732d5596df6 (patch)
tree90f460cc71bf92c30a3f97ccda36bd724b879615
parentec27b7dc5a80567cb13c306db718ae57e16ba89a (diff)
Fix 9 memory leaks.
(Thanks to Brent Cook) With help from tedu@ OK from tedu@
-rw-r--r--lib/libssl/src/crypto/x509v3/v3_purp.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libssl/src/crypto/x509v3/v3_purp.c b/lib/libssl/src/crypto/x509v3/v3_purp.c
index de41a51914a..67fb7baa3e2 100644
--- a/lib/libssl/src/crypto/x509v3/v3_purp.c
+++ b/lib/libssl/src/crypto/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;