From af180da625664c6c2aa1f1497380223fc52ed1df Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 13 Aug 2015 13:23:12 +0200 Subject: [PATCH] libnm: don't assert in nm_connection_get_*() for verified connection Those getters are convenience methods to retrieve the id/type from the NMSettingConnection. If the NMSettingConnection was missing (and thus the connection invalid) we would raise an assertion. Don't be so strict and just silently return NULL. Otherwise, the caller cannot use the functions on unverified connections. --- libnm-core/nm-connection.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 5abb13abe7..1b5112cd60 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1518,7 +1518,8 @@ nm_connection_get_id (NMConnection *connection) g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); s_con = nm_connection_get_setting_connection (connection); - g_return_val_if_fail (s_con != NULL, NULL); + if (!s_con) + return NULL; return nm_setting_connection_get_id (s_con); } @@ -1539,7 +1540,8 @@ nm_connection_get_connection_type (NMConnection *connection) g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); s_con = nm_connection_get_setting_connection (connection); - g_return_val_if_fail (s_con != NULL, NULL); + if (!s_con) + return NULL; return nm_setting_connection_get_connection_type (s_con); }