From 43016d6ebd232bb8285f3adb386041100679f362 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 7 Feb 2020 10:56:44 +0100 Subject: [PATCH] n-dhcp4: avoid double free of NDhcp4Outgoing n_dhcp4_c_connection_start_request() should take ownership of the request only on success. On failure the request is freed by the caller. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/355 --- shared/n-dhcp4/src/n-dhcp4-c-connection.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/n-dhcp4/src/n-dhcp4-c-connection.c b/shared/n-dhcp4/src/n-dhcp4-c-connection.c index 3dd0535678..d4354467d1 100644 --- a/shared/n-dhcp4/src/n-dhcp4-c-connection.c +++ b/shared/n-dhcp4/src/n-dhcp4-c-connection.c @@ -1104,13 +1104,14 @@ int n_dhcp4_c_connection_start_request(NDhcp4CConnection *connection, if (request->userdata.start_time == 0) request->userdata.start_time = timestamp; - n_dhcp4_outgoing_free(connection->request); - connection->request = request; + connection->request = n_dhcp4_outgoing_free(connection->request); r = n_dhcp4_c_connection_send_request(connection, request, timestamp); if (r) return r; + connection->request = request; + return 0; }