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>
This commit is contained in:
Jiří Klimeš 2013-04-22 15:15:33 +02:00 committed by Dan Williams
parent f5507633f8
commit 841c259119

View file

@ -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.
*/