diff options
author | Jens Georg <jgeorg@z400.fritz.box> | 2020-09-11 08:24:53 +0200 |
---|---|---|
committer | Jens Georg <jgeorg@z400.fritz.box> | 2020-09-11 08:24:53 +0200 |
commit | 5c3bab723d5047fd98eba657cf124261f165c347 (patch) | |
tree | a95f8c0ae275caef38bdd44b19b7c323d9ae8086 | |
parent | 2b3ccef1cae202518dd2f69aeb1f8ad1f32bcee8 (diff) | |
download | gssdp_1.0.tar.gz |
client: Plug various leaksgssdp_1.0
Fixes #10
-rw-r--r-- | libgssdp/gssdp-client.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c index 39b8b76..5734d5d 100644 --- a/libgssdp/gssdp-client.c +++ b/libgssdp/gssdp-client.c @@ -463,6 +463,8 @@ gssdp_client_dispose (GObject *object) client->priv->device.host_addr = NULL; } + g_clear_object (&client->priv->device.address_mask); + G_OBJECT_CLASS (gssdp_client_parent_class)->dispose (object); } @@ -2019,17 +2021,24 @@ success: continue; } - device->host_ip = g_strdup (p); + /* If we ended up here with host_ip not being NULL, p is equal to host_ip */ + if (device->host_ip == NULL) + device->host_ip = g_strdup (p); - bytes = (const guint8 *) &s4->sin_addr; - device->host_addr = g_inet_address_new_from_bytes - (bytes, G_SOCKET_FAMILY_IPV4); + if (device->host_addr == NULL) { + bytes = (const guint8 *) &s4->sin_addr; + g_clear_object (&device->host_addr); + device->host_addr = g_inet_address_new_from_bytes + (bytes, G_SOCKET_FAMILY_IPV4); + } s4_mask = (struct sockaddr_in *) ifa->ifa_netmask; memcpy (&(device->mask), s4_mask, sizeof (struct sockaddr_in)); net_addr.s_addr = (in_addr_t) s4->sin_addr.s_addr & (in_addr_t) s4_mask->sin_addr.s_addr; q = inet_ntop (AF_INET, &net_addr, net, sizeof (net)); + + if (device->address_mask == NULL) { // Just assume that the netmask we got is correct int prefix; |