libnm: avoid assertion with invalid connections in _nm_connection_find_base_type_setting()

Functions should behave gracefully with connections that don't verify.
Especially, as _normalize_connection_type() calls
_nm_connection_find_base_type_setting() precisely with an unknown
connection.type.
This commit is contained in:
Thomas Haller 2017-06-01 14:48:54 +02:00
parent 1d6b717401
commit 88c2ccfb4c

View file

@ -598,11 +598,14 @@ _nm_connection_find_base_type_setting (NMConnection *connection)
continue;
} else if (s_iter_prio == setting_prio) {
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
const char *type;
if (!s_con)
return NULL;
return nm_connection_get_setting_by_name (connection,
nm_setting_connection_get_connection_type (s_con));
if (s_con) {
type = nm_setting_connection_get_connection_type (s_con);
if (type)
return nm_connection_get_setting_by_name (connection, type);
}
return NULL;
}
}
setting = s_iter;