if (it->templates)
asn1_template_free(pval, it->templates);
else
- asn1_primitive_free(pval, it);
+ asn1_primitive_free(pval, it, embed);
break;
case ASN1_ITYPE_MSTRING:
- asn1_primitive_free(pval, it);
+ asn1_primitive_free(pval, it, embed);
break;
case ASN1_ITYPE_CHOICE:
asn1_enc_free(pval, it);
/*
* If we free up as normal we will invalidate any ANY DEFINED BY
- * field and we wont be able to determine the type of the field it
+ * field and we won't be able to determine the type of the field it
* defines. So free up in reverse order.
*/
tt = it->templates + it->tcount;
}
}
-void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
+void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
{
int utype;
if (it) {
const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
- if (pf && pf->prim_free) {
+ if (embed) {
+ if (pf && pf->prim_clear) {
+ pf->prim_clear(pval, it);
+ return;
+ }
+ } else if (pf && pf->prim_free) {
pf->prim_free(pval, it);
return;
}
break;
case V_ASN1_ANY:
- asn1_primitive_free(pval, NULL);
+ asn1_primitive_free(pval, NULL, 0);
OPENSSL_free(*pval);
break;
default:
- ASN1_STRING_free((ASN1_STRING *)*pval);
+ asn1_string_embed_free((ASN1_STRING *)*pval, embed);
break;
}
*pval = NULL;