summaryrefslogtreecommitdiff
path: root/lib/libcrypto/x509
diff options
context:
space:
mode:
authorLoganaden Velvindron <logan@cvs.openbsd.org>2014-06-28 18:25:25 +0000
committerLoganaden Velvindron <logan@cvs.openbsd.org>2014-06-28 18:25:25 +0000
commit74bcf83e4d4defbae5d6a945661d29eadc4e6fa1 (patch)
treed86f98f8011fcec1633d64b5627b953cc707b8b7 /lib/libcrypto/x509
parent4d40a005624d12359560221614032971f788d8e2 (diff)
Fix a memory leak and another one that occurs in the error paths.
(Thanks to Brent Cook) OK from tedu@
Diffstat (limited to 'lib/libcrypto/x509')
-rw-r--r--lib/libcrypto/x509/x509_att.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libcrypto/x509/x509_att.c b/lib/libcrypto/x509/x509_att.c
index f2668d189da..bbbeba50ac1 100644
--- a/lib/libcrypto/x509/x509_att.c
+++ b/lib/libcrypto/x509/x509_att.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_att.c,v 1.8 2014/06/12 15:49:31 deraadt Exp $ */
+/* $OpenBSD: x509_att.c,v 1.9 2014/06/28 18:25:24 logan Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -333,8 +333,11 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
* at least one value but some types use and zero length SET and
* require this.
*/
- if (attrtype == 0)
+ if (attrtype == 0) {
+ ASN1_STRING_free(stmp);
return 1;
+ }
+
if (!(ttmp = ASN1_TYPE_new()))
goto err;
if ((len == -1) && !(attrtype & MBSTRING_FLAG)) {
@@ -347,6 +350,7 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
return 1;
err:
+ ASN1_STRING_free(stmp);
X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
return 0;
}