How to diagnose memory leak in ASN.1 structure? #21916
-
Using OpenSSL 3.0.10 I have defined a new CRL Entry Extension (based on BSI TR-03145-5 Appendix B). For every instance of the extension that is created (and later discarded) Valgrind reports a leak of 72 bytes in 3 blocks. E.g. for 4 CRL entries this adds up to 288 bytes:
I am at a loss as to which part is not being freed correctly and why. I suspect some silly mistake in my use of the ASN1 macros. The structure is declared in a header file
and defined in a body together with the extension method
The main application creates an OID to add the extension method (error handling omitted):
During CRL creation, for every entry the extension is created, added and then freed (error handling omitted):
Explicitly freeing and NULLing all the individual components before REVOCATION_DETAILS_free() does not make any difference. There remains a constant 72 bytes per REVOCATION_DETAILS object that is not freed. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try printing out the fields of the object right after REVOCATION_DETAILS_new() is called.. |
Beta Was this translation helpful? Give feedback.
Try printing out the fields of the object right after REVOCATION_DETAILS_new() is called..
I suspect rd->additionalInfo is not NULL.
If they are not NULL and then you are then doing rd->additionalInfo = ASN1_PRINTABLESTRING_new()
you will end up with floating memory.