From 841c2591193fb1031410a0a34dac809fa85a77bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Mon, 22 Apr 2013 15:15:33 +0200 Subject: [PATCH] libnm-util: make nm_connection_replace_settings_from_connection() safer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 'connection' and 'new_connection' arguments are the same object make the function no-op and simply return true. Otherwise 'connection's settings are removed, making it invalid. Signed-off-by: Jiří Klimeš --- libnm-util/nm-connection.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 1ac579bfa9..a67ae39e7e 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -506,6 +506,11 @@ nm_connection_replace_settings_from_connection (NMConnection *connection, if (error) g_return_val_if_fail (*error == NULL, FALSE); + /* When 'connection' and 'new_connection' are the same object simply return + * in order not to destroy 'connection' */ + if (connection == new_connection) + return TRUE; + /* No need to validate permissions like nm_connection_replace_settings() * since we're dealing with an NMConnection which has already done that. */