diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2015-08-26 12:30:56 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2015-08-26 12:30:56 +0200 |
commit | e6b18ffaea7d557eec3028a37c043da67a78550c (patch) | |
tree | 4b4a00a8a1c61b7164a586b8edcb6c5c3adf5c02 /src/libsystemd-network/sd-dhcp-client.c | |
parent | 31ab68df9a4d7345ae2a7ebf03314a7ed9df2685 (diff) |
sd-dhcp: don't randomly ref objects
In our API design, getter-functions don't ref objects. Calls like
foo_get_bar() will not ref 'bar'. We never do that and there is no real
reason to do it in single threaded APIs. If you need a ref-count, you
better take it yourself *BEFORE* doing anything else on the parent object
(as this might invalidate your pointer).
Right now, sd_dhcp?_get_lease() refs the lease it returns. A lot of
code-paths in systemd do not expect this and thus leak the lease
reference. Fix this by changing the API to not ref returned objects.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-client.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 6a0d270739..46104afded 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -348,7 +348,7 @@ int sd_dhcp_client_get_lease(sd_dhcp_client *client, sd_dhcp_lease **ret) { client->state != DHCP_STATE_REBINDING) return -EADDRNOTAVAIL; - *ret = sd_dhcp_lease_ref(client->lease); + *ret = client->lease; return 0; } |