From: Dr. Stephen Henson Date: Tue, 6 Oct 2015 21:53:48 +0000 (+0100) Subject: embed support for CHOICE type X-Git-Tag: OpenSSL_1_1_0-pre1~441 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44c734e95c4242af5ccfd7e5c4653eb196705cb9;p=openssl embed support for CHOICE type Reviewed-by: Rich Salz --- diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c index bd955d9848..1e778858ac 100644 --- a/crypto/asn1/tasn_fre.c +++ b/crypto/asn1/tasn_fre.c @@ -125,8 +125,10 @@ static void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, } if (asn1_cb) asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); - OPENSSL_free(*pval); - *pval = NULL; + if (embed == 0) { + OPENSSL_free(*pval); + *pval = NULL; + } break; case ASN1_ITYPE_EXTERN: diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index 294912c188..13db8676fc 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -142,9 +142,13 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) return 1; } } - *pval = OPENSSL_zalloc(it->size); - if (!*pval) - goto memerr; + if (embed) { + memset(*pval, 0, it->size); + } else { + *pval = OPENSSL_zalloc(it->size); + if (!*pval) + goto memerr; + } asn1_set_choice_selector(pval, -1, it); if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL)) goto auxerr;