libnm-util: fix two bugs in nm_setting_bond_get_option()
The function documents that it returns FALSE if idx is out of range, so don't g_return_val_if_fail() in that case. Also, free the return value from g_hash_table_get_keys().
This commit is contained in:
@@ -160,7 +160,6 @@ nm_setting_bond_get_option (NMSettingBond *setting,
|
|||||||
const char **out_value)
|
const char **out_value)
|
||||||
{
|
{
|
||||||
NMSettingBondPrivate *priv;
|
NMSettingBondPrivate *priv;
|
||||||
guint32 num_keys;
|
|
||||||
GList *keys;
|
GList *keys;
|
||||||
const char *_key = NULL, *_value = NULL;
|
const char *_key = NULL, *_value = NULL;
|
||||||
|
|
||||||
@@ -168,8 +167,8 @@ nm_setting_bond_get_option (NMSettingBond *setting,
|
|||||||
|
|
||||||
priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
||||||
|
|
||||||
num_keys = nm_setting_bond_get_num_options (setting);
|
if (idx >= nm_setting_bond_get_num_options (setting))
|
||||||
g_return_val_if_fail (idx < num_keys, FALSE);
|
return FALSE;
|
||||||
|
|
||||||
keys = g_hash_table_get_keys (priv->options);
|
keys = g_hash_table_get_keys (priv->options);
|
||||||
_key = g_list_nth_data (keys, idx);
|
_key = g_list_nth_data (keys, idx);
|
||||||
@@ -180,6 +179,7 @@ nm_setting_bond_get_option (NMSettingBond *setting,
|
|||||||
if (out_value)
|
if (out_value)
|
||||||
*out_value = _value;
|
*out_value = _value;
|
||||||
|
|
||||||
|
g_list_free (keys);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user