chiark / gitweb /
sd-dhcp-server: fix a leak
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Fri, 13 Jun 2014 20:54:22 +0000 (22:54 +0200)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 18 Jun 2014 21:21:00 +0000 (23:21 +0200)
We must use free instead of dhcp_lease_free here to avoid freeing
client_id.data.

src/libsystemd-network/sd-dhcp-server.c

index 4ce1054..d949502 100644 (file)
@@ -697,8 +697,10 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
                                 lease->address = req->requested_ip;
                                 lease->client_id.data = memdup(req->client_id.data,
                                                                req->client_id.length);
-                                if (!lease->client_id.data)
+                                if (!lease->client_id.data) {
+                                        free(lease);
                                         return -ENOMEM;
+                                }
                                 lease->client_id.length = req->client_id.length;
                         } else
                                 lease = existing_lease;