diff options
author | Richard Levitte <levitte@openssl.org> | 2017-10-24 18:32:22 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-10-24 20:52:12 +0200 |
commit | fe6fcd31546db1ab019e55edd15c953c5b358559 (patch) | |
tree | 00c960a05e3f1645bd79dc8c5312dc4b0fcc16d5 /crypto | |
parent | 03996c19c30575c48b254f10625d24f86058605b (diff) | |
download | openssl-fe6fcd31546db1ab019e55edd15c953c5b358559.zip openssl-fe6fcd31546db1ab019e55edd15c953c5b358559.tar.gz openssl-fe6fcd31546db1ab019e55edd15c953c5b358559.tar.bz2 |
asn1_item_embed_new(): if locking failed, don't call asn1_item_embed_free()
asn1_item_embed_free() will try unlocking and fail in this case, and
since the new item was just allocated on the heap, free it directly
with OPENSSL_free() instead.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/4579)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asn1/tasn_new.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index 63a4b38..11c8040 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -124,8 +124,13 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) goto memerr; } /* 0 : init. lock */ - if (asn1_do_lock(pval, 0, it) < 0) - goto memerr2; + if (asn1_do_lock(pval, 0, it) < 0) { + if (!embed) { + OPENSSL_free(*pval); + *pval = NULL; + } + goto memerr; + } asn1_enc_init(pval, it); for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) { pseqval = asn1_get_field_ptr(pval, tt); |