Fix potential memory leaks with BN_to_ASN1_INTEGER