chiark / gitweb /
sd-dhcp-lease/sd-network: modernization and fix leak
authorTom Gundersen <teg@jklm.no>
Mon, 19 May 2014 15:44:38 +0000 (17:44 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 19 May 2014 16:14:56 +0000 (18:14 +0200)
src/libsystemd-network/sd-dhcp-lease.c
src/network/sd-network.c

index 4993fe3..cf71f11 100644 (file)
@@ -174,6 +174,7 @@ sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) {
                 free(lease->hostname);
                 free(lease->domainname);
                 free(lease->dns);
+                free(lease->ntp);
                 free(lease);
         }
 
index 64e3aaa..7ae15ed 100644 (file)
@@ -142,8 +142,8 @@ _public_ int sd_network_get_link_operational_state(unsigned index, char **state)
 }
 
 _public_ int sd_network_get_dhcp_lease(unsigned index, sd_dhcp_lease **ret) {
+        _cleanup_free_ char *p = NULL, *s = NULL;
         sd_dhcp_lease *lease;
-        char *p, *s = NULL;
         int r;
 
         assert_return(index, -EINVAL);
@@ -153,12 +153,10 @@ _public_ int sd_network_get_dhcp_lease(unsigned index, sd_dhcp_lease **ret) {
                 return -ENOMEM;
 
         r = parse_env_file(p, NEWLINE, "DHCP_LEASE", &s, NULL);
-        free(p);
 
-        if (r < 0) {
-                free(s);
+        if (r < 0)
                 return r;
-        else if (!s)
+        else if (!s)
                 return -EIO;
 
         r = dhcp_lease_load(s, &lease);