de-duplicate cleanup of name-related data in error paths

"name" being both the ipv6 dns info and our own socket label.

sort-of amends 9d22641b.
This commit is contained in:
Oswald Buddenhagen 2015-09-06 21:02:23 +02:00
parent 167964933f
commit 9a0403f446

View File

@ -536,14 +536,22 @@ socket_connected( conn_t *conn )
} }
static void static void
socket_connect_bail( conn_t *conn ) socket_cleanup_names( conn_t *conn )
{ {
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
freeaddrinfo( conn->addrs ); if (conn->addrs) {
conn->addrs = 0; freeaddrinfo( conn->addrs );
conn->addrs = 0;
}
#endif #endif
free( conn->name ); free( conn->name );
conn->name = 0; conn->name = 0;
}
static void
socket_connect_bail( conn_t *conn )
{
socket_cleanup_names( conn );
conn->callbacks.connect( 0, conn->callback_aux ); conn->callbacks.connect( 0, conn->callback_aux );
} }
@ -554,14 +562,7 @@ socket_close( conn_t *sock )
{ {
if (sock->fd >= 0) if (sock->fd >= 0)
socket_close_internal( sock ); socket_close_internal( sock );
free( sock->name ); socket_cleanup_names( sock );
sock->name = 0;
#ifdef HAVE_IPV6
if (sock->addrs) {
freeaddrinfo( sock->addrs );
sock->addrs = 0;
}
#endif
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
if (sock->ssl) { if (sock->ssl) {
SSL_free( sock->ssl ); SSL_free( sock->ssl );