summaryrefslogtreecommitdiff
path: root/libnm-util/nm-connection.c
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2013-04-22 15:15:33 +0200
committerDan Williams <dcbw@redhat.com>2013-04-22 10:15:53 -0500
commit841c2591193fb1031410a0a34dac809fa85a77bc (patch)
tree825793fc9df327d7e5c5e3af522ce1242230501a /libnm-util/nm-connection.c
parentf5507633f81571fbfa0c371d9e108174b8c070fe (diff)
downloadNetworkManager-841c2591193fb1031410a0a34dac809fa85a77bc.tar.gz
libnm-util: make nm_connection_replace_settings_from_connection() safer
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š <jklimes@redhat.com>
Diffstat (limited to 'libnm-util/nm-connection.c')
-rw-r--r--libnm-util/nm-connection.c5
1 files changed, 5 insertions, 0 deletions
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.
*/