[openssl-dev] Is X509_free(NULL) ok?

Viktor Dukhovni openssl-users at dukhovni.org
Wed Dec 20 23:58:41 UTC 2017



> On Dec 20, 2017, at 5:50 PM, Ray Satiro via openssl-dev <openssl-dev at openssl.org> wrote:
> 
> 'm trying to figure out whether it's supported to call X509_free(NULL)
> in 1.0.2 and beyond. It's not documented what action occurs when the
> pointer is null. Also generally speaking is it supported to call openssl
> free functions with null pointers?


All ASN.1 objects (such as X509 *) that are implemented via
IMPLEMENT_ASN1_FUNCTIONS(typename) are freed by ASN1_item_free(),
which I believe handles NULL inputs.

If you don't see immediate crashes on trying it, you can use it
on NULL inputs with confidence that this is intentional and not
going to change.

-- 
-- 
	Viktor.



More information about the openssl-dev mailing list