summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2020-03-11 14:11:09 +0000
committerSimon McVittie <smcv@collabora.com>2020-03-11 14:11:09 +0000
commite70f19d48fda463566ef315ab29e7e606b843e9f (patch)
tree79d1acb92a72383068bda90b2bf5362d6e45a2cd /dbus
parent041cadb73836d1add99daa1c4847a5033fb32d61 (diff)
parent682e61919692d7b7a5a15ef995641b2d70ed82b2 (diff)
downloaddbus-e70f19d48fda463566ef315ab29e7e606b843e9f.tar.gz
Merge branch 'mr143-but-unix' into 'master'
sysdeps-unix: Don't leak struct addrinfo on OOM during connect() See merge request dbus/dbus!144
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-sysdeps-unix.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index c91c05ef..4607f537 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1411,7 +1411,8 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
DBusSocket fd = DBUS_SOCKET_INIT;
int res;
struct addrinfo hints;
- struct addrinfo *ai, *tmp;
+ struct addrinfo *ai = NULL;
+ const struct addrinfo *tmp;
DBusError *connect_error;
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
@@ -1450,7 +1451,6 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
{
if (!_dbus_open_socket (&fd.fd, tmp->ai_family, SOCK_STREAM, 0, error))
{
- freeaddrinfo(ai);
_DBUS_ASSERT_ERROR_IS_SET(error);
_dbus_socket_invalidate (&fd);
goto out;
@@ -1491,7 +1491,6 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
break;
}
- freeaddrinfo(ai);
if (!_dbus_socket_is_valid (fd))
{
@@ -1523,6 +1522,9 @@ _dbus_connect_tcp_socket_with_nonce (const char *host,
}
out:
+ if (ai != NULL)
+ freeaddrinfo (ai);
+
while ((connect_error = _dbus_list_pop_first (&connect_errors)))
{
dbus_error_free (connect_error);