Add debugging info to new ASN1 code to trace memory leaks.
[openssl.git] / crypto / pkcs7 / pk7_asn1.c
index 9c5eda2..34561df 100644 (file)
@@ -136,12 +136,22 @@ ASN1_SEQUENCE(PKCS7_ENVELOPE) = {
 
 IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
 
-ASN1_SEQUENCE(PKCS7_RECIP_INFO) = {
+/* Minor tweak to operation: free up X509 */
+static int ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it)
+{
+       if(operation == ASN1_OP_FREE_POST) {
+               PKCS7_RECIP_INFO *ri = (PKCS7_RECIP_INFO *)*pval;
+               X509_free(ri->cert);
+       }
+       return 1;
+}
+
+ASN1_SEQUENCE_cb(PKCS7_RECIP_INFO, ri_cb) = {
        ASN1_SIMPLE(PKCS7_RECIP_INFO, version, ASN1_INTEGER),
        ASN1_SIMPLE(PKCS7_RECIP_INFO, issuer_and_serial, PKCS7_ISSUER_AND_SERIAL),
        ASN1_SIMPLE(PKCS7_RECIP_INFO, key_enc_algor, X509_ALGOR),
        ASN1_SIMPLE(PKCS7_RECIP_INFO, enc_key, ASN1_OCTET_STRING)
-} ASN1_SEQUENCE_END(PKCS7_RECIP_INFO);
+} ASN1_SEQUENCE_END_cb(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO);
 
 IMPLEMENT_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)