sd-dhcp: don't randomly ref objects
authorDavid Herrmann <dh.herrmann@gmail.com>
Wed, 26 Aug 2015 10:30:56 +0000 (12:30 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Wed, 26 Aug 2015 10:30:56 +0000 (12:30 +0200)
commite6b18ffaea7d557eec3028a37c043da67a78550c
tree4b4a00a8a1c61b7164a586b8edcb6c5c3adf5c02
parent31ab68df9a4d7345ae2a7ebf03314a7ed9df2685
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.
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp6-client.c
src/libsystemd-network/test-dhcp-client.c
src/network/networkd-dhcp4.c