summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2021-06-21 10:33:10 +1000
committerPauli <pauli@openssl.org>2021-06-22 12:43:21 +1000
commitd65d2963839433bb4f15525df37d0f4f799466e5 (patch)
treedf85e156a83fc7b49857bd720fa880f9b2c903e2 /crypto/asn1
parent0c7ec1d2c3a47235ed1e5f9c65769955a41b8b26 (diff)
asn1: properly clean up on failed BIO creation
Fixes coverity 1486070 through 1486077 and 1486079 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15841)
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/asn1_parse.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/asn1/asn1_parse.c b/crypto/asn1/asn1_parse.c
index a131713d73..04d7ef66cf 100644
--- a/crypto/asn1/asn1_parse.c
+++ b/crypto/asn1/asn1_parse.c
@@ -27,6 +27,7 @@ static int asn1_print_info(BIO *bp, long offset, int depth, int hl, long len,
int pop_f_prefix = 0;
long saved_indent = -1;
int i = 0;
+ BIO *bio = NULL;
if (constructed & V_ASN1_CONSTRUCTED)
p = "cons: ";
@@ -43,7 +44,8 @@ static int asn1_print_info(BIO *bp, long offset, int depth, int hl, long len,
}
if (bp != NULL) {
if (BIO_set_prefix(bp, str) <= 0) {
- if ((bp = BIO_push(BIO_new(BIO_f_prefix()), bp)) == NULL)
+ if ((bio = BIO_new(BIO_f_prefix())) == NULL
+ || (bp = BIO_push(bio, bp)) == NULL)
goto err;
pop_f_prefix = 1;
}
@@ -72,10 +74,9 @@ static int asn1_print_info(BIO *bp, long offset, int depth, int hl, long len,
err:
if (saved_indent >= 0)
BIO_set_indent(bp, saved_indent);
- if (pop_f_prefix) {
+ if (pop_f_prefix)
BIO_pop(bp);
- BIO_free(bp);
- }
+ BIO_free(bio);
return i;
}