tor_free(nickname);
tor_free(nn2);
- if (cert)
- tor_x509_cert_impl_free_(cert);
- if (idcert)
- tor_x509_cert_impl_free_(idcert);
- if (authcert)
- tor_x509_cert_impl_free_(authcert);
+ tor_x509_cert_impl_free(cert);
+ tor_x509_cert_impl_free(idcert);
+ tor_x509_cert_impl_free(authcert);
crypto_pk_free(rsa);
crypto_pk_free(rsa_auth);
size_t r,w;
tor_tls_get_n_raw_bytes(tls,&r,&w); /* ensure written_by_tls is updated */
}
- tor_tls_impl_free_(tls->ssl);
+ tor_tls_impl_free(tls->ssl);
tls->ssl = NULL;
#ifdef ENABLE_OPENSSL
tls->negotiated_callback = NULL;
rv = 0;
done:
- if (cert)
- tor_x509_cert_impl_free_(cert);
- if (id_cert)
- tor_x509_cert_impl_free_(id_cert);
+ tor_x509_cert_impl_free(cert);
+ tor_x509_cert_impl_free(id_cert);
tor_x509_cert_free(peer_x509);
tor_x509_cert_free(id_x509);
unsigned key_lifetime,
unsigned flags);
void tor_tls_impl_free_(tor_tls_impl_t *ssl);
+#define tor_tls_impl_free(tls) \
+ FREE_AND_NULL(tor_tls_impl_t, tor_tls_impl_free_, (tls))
-void tor_tls_context_impl_free(tor_tls_context_impl_t *);
+void tor_tls_context_impl_free_(tor_tls_context_impl_t *);
+#define tor_tls_context_impl_free(ctx) \
+ FREE_AND_NULL(tor_tls_context_impl_t, tor_tls_context_impl_free_, (ctx))
#ifdef ENABLE_OPENSSL
tor_tls_t *tor_tls_get_by_ssl(const struct ssl_st *ssl);
}
void
-tor_tls_context_impl_free(tor_tls_context_impl_t *ctx)
+tor_tls_context_impl_free_(tor_tls_context_impl_t *ctx)
{
+ if (!ctx)
+ return;
PR_Close(ctx);
}
{
// XXXX This will close the underlying fd, which our OpenSSL version does
// not do!
+ if (!tls)
+ return;
PR_Close(tls);
}
}
void
-tor_tls_context_impl_free(struct ssl_ctx_st *ctx)
+tor_tls_context_impl_free_(struct ssl_ctx_st *ctx)
{
if (!ctx)
return;
void
tor_tls_impl_free_(tor_tls_impl_t *ssl)
{
+ if (!ssl)
+ return;
+
#ifdef SSL_set_tlsext_host_name
SSL_set_tlsext_host_name(ssl, NULL);
#endif
{
if (! cert)
return;
- if (cert->cert)
- tor_x509_cert_impl_free_(cert->cert);
+ tor_x509_cert_impl_free(cert->cert);
#ifdef ENABLE_OPENSSL
tor_free(cert->encoded);
#endif
err:
tor_free(cert);
log_err(LD_CRYPTO, "Couldn't wrap encoded X509 certificate.");
- tor_x509_cert_impl_free_(x509_cert);
+ tor_x509_cert_impl_free(x509_cert);
return NULL;
}
int future_tolerance);
void tor_x509_cert_impl_free_(tor_x509_cert_impl_t *cert);
+#define tor_x509_cert_impl_free(cert) \
+ FREE_AND_NULL(tor_x509_cert_impl_t, tor_x509_cert_impl_free_, (cert))
tor_x509_cert_impl_t *tor_x509_cert_impl_dup_(tor_x509_cert_impl_t *cert);
#ifdef ENABLE_OPENSSL
int tor_x509_cert_set_cached_der_encoding(tor_x509_cert_t *cert);
done:
UNMOCK(try_to_extract_certs_from_tls);
- if (cert1)
- tor_x509_cert_impl_free_(cert1);
- if (cert2)
- tor_x509_cert_impl_free_(cert2);
+ tor_x509_cert_impl_free(cert1);
+ tor_x509_cert_impl_free(cert2);
tor_free(tls);
crypto_pk_free(k);
}
done:
crypto_pk_free(pk1);
crypto_pk_free(pk2);
- if (impl)
- tor_x509_cert_impl_free_(impl);
+ tor_x509_cert_impl_free(impl);
UNMOCK(crypto_digest);
teardown_capture_of_logs();
}