From fb06cda7239cce9449a3af6cecd85fa9063362da Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 2 Mar 2012 14:20:55 -0500 Subject: [PATCH] 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(). --- libnm-util/nm-setting-bond.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c index 34767a010..50cad2da7 100644 --- a/libnm-util/nm-setting-bond.c +++ b/libnm-util/nm-setting-bond.c @@ -160,7 +160,6 @@ nm_setting_bond_get_option (NMSettingBond *setting, const char **out_value) { NMSettingBondPrivate *priv; - guint32 num_keys; GList *keys; const char *_key = NULL, *_value = NULL; @@ -168,8 +167,8 @@ nm_setting_bond_get_option (NMSettingBond *setting, priv = NM_SETTING_BOND_GET_PRIVATE (setting); - num_keys = nm_setting_bond_get_num_options (setting); - g_return_val_if_fail (idx < num_keys, FALSE); + if (idx >= nm_setting_bond_get_num_options (setting)) + return FALSE; keys = g_hash_table_get_keys (priv->options); _key = g_list_nth_data (keys, idx); @@ -180,6 +179,7 @@ nm_setting_bond_get_option (NMSettingBond *setting, if (out_value) *out_value = _value; + g_list_free (keys); return TRUE; }