sd-dhcp6-client: Reference and unreference a stored lease
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 19 Sep 2018 00:32:26 +0000 (18:32 -0600)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 19 Sep 2018 19:45:18 +0000 (13:45 -0600)
In order to be able to properly free a DHCPv6 lease, unreference the
previous lease and reference the new one.

src/libsystemd-network/sd-dhcp6-client.c

index 9969b01..b306f07 100644 (file)
@@ -390,7 +390,8 @@ static void client_notify(sd_dhcp6_client *client, int event) {
 static void client_set_lease(sd_dhcp6_client *client, sd_dhcp6_lease *lease) {
         assert(client);
 
-        client->lease = lease;
+        (void) sd_dhcp6_lease_unref(client->lease);
+        client->lease = sd_dhcp6_lease_ref(lease);
 }
 
 static int client_reset(sd_dhcp6_client *client) {