Maybe add a NULL pointer check? OpenSSL is pretty cavalier in allowing NULL pointers everywhere.