summaryrefslogtreecommitdiff
path: root/lib/libcrypto/asn1
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-04-22 20:31:58 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-04-22 20:31:58 +0000
commitf06a7133e096f8ad83526c98775f29101c868a72 (patch)
tree1cfe2424eb0e7af00aa478b2c1a9d5862378d228 /lib/libcrypto/asn1
parent9014fdfcd1c1f82ca91f413c59483f1ffe418f2c (diff)
fix memory leaks. from Dirk Engling
Diffstat (limited to 'lib/libcrypto/asn1')
-rw-r--r--lib/libcrypto/asn1/f_enum.c11
-rw-r--r--lib/libcrypto/asn1/f_int.c11
-rw-r--r--lib/libcrypto/asn1/f_string.c11
3 files changed, 12 insertions, 21 deletions
diff --git a/lib/libcrypto/asn1/f_enum.c b/lib/libcrypto/asn1/f_enum.c
index 98fa3122661..5c42cdff015 100644
--- a/lib/libcrypto/asn1/f_enum.c
+++ b/lib/libcrypto/asn1/f_enum.c
@@ -158,8 +158,6 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,
ERR_R_MALLOC_FAILURE);
- if (s != NULL)
- free(s);
goto err;
}
s = sp;
@@ -191,12 +189,11 @@ a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
}
bs->length = num;
bs->data = s;
- ret = 1;
+ return (1);
-err:
- if (0) {
err_sl:
- ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
- }
+ ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
+err:
+ free(s);
return (ret);
}
diff --git a/lib/libcrypto/asn1/f_int.c b/lib/libcrypto/asn1/f_int.c
index 3f671d1c490..41e0e752264 100644
--- a/lib/libcrypto/asn1/f_int.c
+++ b/lib/libcrypto/asn1/f_int.c
@@ -162,8 +162,6 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER,
ERR_R_MALLOC_FAILURE);
- if (s != NULL)
- free(s);
goto err;
}
s = sp;
@@ -195,12 +193,11 @@ a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
}
bs->length = num;
bs->data = s;
- ret = 1;
+ return (1);
-err:
- if (0) {
err_sl:
- ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
- }
+ ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
+err:
+ free(s);
return (ret);
}
diff --git a/lib/libcrypto/asn1/f_string.c b/lib/libcrypto/asn1/f_string.c
index c213c7a88d3..14f6554ab33 100644
--- a/lib/libcrypto/asn1/f_string.c
+++ b/lib/libcrypto/asn1/f_string.c
@@ -154,8 +154,6 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING,
ERR_R_MALLOC_FAILURE);
- if (s != NULL)
- free(s);
goto err;
}
s = sp;
@@ -187,12 +185,11 @@ a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
}
bs->length = num;
bs->data = s;
- ret = 1;
+ return (1);
-err:
- if (0) {
err_sl:
- ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
- }
+ ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
+err:
+ free(s);
return (ret);
}