From 13aaad7c5bf6fd0a0cf105fb8b042dffdb11d9f3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 10 Sep 2018 14:31:23 +0200 Subject: [PATCH] dhcp: fix leak in dhclient's dhclient_start() Fixes: 5d6d5cd136e36ed2815b7c719ada32bc6d22b481 (cherry picked from commit c87faf07a10900804b914057a2673e0e070b0af4) (cherry picked from commit 8f9240de966e431c2b7623e88a4e37700086d355) (cherry picked from commit c740726b570c004635c43bc50c5dbbcde10cfd2e) (cherry picked from commit 0a69572cae6c2154a178de17c82674b14565cfaa) --- src/dhcp/nm-dhcp-dhclient.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index f20158c64d..4e71f55412 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -386,11 +386,15 @@ dhclient_start (NMDhcpClient *client, if (g_file_copy (src, dst, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { /* Success; use the preferred leasefile path */ g_free (priv->lease_file); - priv->lease_file = g_strdup (g_file_get_path (dst)); + priv->lease_file = g_file_get_path (dst); } else { + gs_free char *s_path = NULL; + gs_free char *d_path = NULL; + /* Failure; just use the existing leasefile */ _LOGW ("failed to copy leasefile %s to %s: %s", - g_file_get_path (src), g_file_get_path (dst), + (s_path = g_file_get_path (src)), + (d_path = g_file_get_path (dst)), error->message); g_clear_error (&error); }