mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
2008-06-05 Tambet Ingo <tambet@gmail.com>
Fix memory leaks. * system-settings/src/nm-system-config-hal-manager.c (get_type_for_udi): Free data returned from dbus method call. * system-settings/src/nm-polkit-helpers.c (check_polkit_privileges): dbus_g_method_get_sender() returns a duplicated string, free it when done. (check_polkit_privileges): Looks like policykit sometimes returns error and non-null return value, don't leak errors in that case. * system-settings/src/main.c (find_plugin): Don't leak existing plugin names. (load_stuff): Don't leak device list and list items. (have_connection_for_device): Don't leak connection list. * system-settings/plugins/keyfile/reader.c (read_one_setting_value): Free the data received from g_keyfile_get_*. * system-settings/plugins/ifcfg-suse/parser.c (READ_WEP_KEY): Free the key when the security object is updated. * src/supplicant-manager/nm-supplicant-interface.c (scan_results_cb): Free data returned from dbus method call. (iface_state_cb): Ditto. (add_network_cb): Ditto. (nm_supplicant_interface_add_cb): Don't make another copy of already duplicated object path. (nm_supplicant_interface_add_to_supplicant): Free the driver GValue when done. * src/supplicant-manager/nm-supplicant-config.c (ADD_STRING_LIST_VAL): Fix a memory leak. * src/nm-manager.c (free_get_settings_info): Free the allocated memory slice. (list_connections_cb): Free data returned from dbus method call. (system_settings_get_unmanaged_devices_cb): Ditto. * src/nm-device-802-11-wireless.c (device_cleanup): Free ssid. * system-settings/plugins/ifcfg-suse/shvar.c (svCloseFile): * system-settings/plugins/ifcfg-fedora/shvar.c (svCloseFile): * src/backends/shvar.c (svCloseFile): Free the duplicated content of the GList. * libnm-util/nm-setting.c (nm_setting_from_hash): Free the constructor arguments after the object is created. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3721 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
a538a68ea5
commit
d95e330f96
51
ChangeLog
51
ChangeLog
|
@ -1,3 +1,54 @@
|
|||
2008-06-05 Tambet Ingo <tambet@gmail.com>
|
||||
|
||||
Fix memory leaks.
|
||||
|
||||
* system-settings/src/nm-system-config-hal-manager.c (get_type_for_udi):
|
||||
Free data returned from dbus method call.
|
||||
|
||||
* system-settings/src/nm-polkit-helpers.c (check_polkit_privileges):
|
||||
dbus_g_method_get_sender() returns a duplicated string, free it
|
||||
when done.
|
||||
(check_polkit_privileges): Looks like policykit sometimes returns
|
||||
error and non-null return value, don't leak errors in that case.
|
||||
|
||||
* system-settings/src/main.c (find_plugin): Don't leak existing
|
||||
plugin names.
|
||||
(load_stuff): Don't leak device list and list items.
|
||||
(have_connection_for_device): Don't leak connection list.
|
||||
|
||||
* system-settings/plugins/keyfile/reader.c (read_one_setting_value):
|
||||
Free the data received from g_keyfile_get_*.
|
||||
|
||||
* system-settings/plugins/ifcfg-suse/parser.c (READ_WEP_KEY): Free
|
||||
the key when the security object is updated.
|
||||
|
||||
* src/supplicant-manager/nm-supplicant-interface.c (scan_results_cb):
|
||||
Free data returned from dbus method call.
|
||||
(iface_state_cb): Ditto.
|
||||
(add_network_cb): Ditto.
|
||||
(nm_supplicant_interface_add_cb): Don't make another copy of already
|
||||
duplicated object path.
|
||||
(nm_supplicant_interface_add_to_supplicant): Free the driver GValue
|
||||
when done.
|
||||
|
||||
* src/supplicant-manager/nm-supplicant-config.c
|
||||
(ADD_STRING_LIST_VAL): Fix a memory leak.
|
||||
|
||||
* src/nm-manager.c (free_get_settings_info): Free the allocated
|
||||
memory slice.
|
||||
(list_connections_cb): Free data returned from dbus method call.
|
||||
(system_settings_get_unmanaged_devices_cb): Ditto.
|
||||
|
||||
* src/nm-device-802-11-wireless.c (device_cleanup): Free ssid.
|
||||
|
||||
* system-settings/plugins/ifcfg-suse/shvar.c (svCloseFile):
|
||||
* system-settings/plugins/ifcfg-fedora/shvar.c (svCloseFile):
|
||||
* src/backends/shvar.c (svCloseFile): Free the duplicated content
|
||||
of the GList.
|
||||
|
||||
* libnm-util/nm-setting.c (nm_setting_from_hash): Free the constructor
|
||||
arguments after the object is created.
|
||||
|
||||
2008-06-04 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/Makefile.am
|
||||
|
|
|
@ -107,6 +107,7 @@ nm_setting_from_hash (GType setting_type,
|
|||
{
|
||||
NMSetting *setting;
|
||||
NMSettingFromHashInfo info;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (G_TYPE_IS_INSTANTIATABLE (setting_type), NULL);
|
||||
g_return_val_if_fail (hash != NULL, NULL);
|
||||
|
@ -119,6 +120,11 @@ nm_setting_from_hash (GType setting_type,
|
|||
|
||||
setting = (NMSetting *) g_object_newv (setting_type, info.n_params, info.params);
|
||||
|
||||
for (i = 0; i < info.n_params; i++) {
|
||||
GValue *v = &info.params[i].value;
|
||||
g_value_unset (v);
|
||||
}
|
||||
|
||||
g_free (info.params);
|
||||
g_type_class_unref (info.class);
|
||||
|
||||
|
|
|
@ -392,6 +392,7 @@ svCloseFile(shvarFile *s)
|
|||
}
|
||||
g_free(s->fileName);
|
||||
g_list_free(s->freeList);
|
||||
g_list_foreach (s->lineList, (GFunc) g_free, NULL);
|
||||
g_list_free(s->lineList); /* implicitly frees s->current */
|
||||
g_free(s);
|
||||
return 0;
|
||||
|
|
|
@ -828,6 +828,12 @@ device_cleanup (NMDevice80211Wireless *self)
|
|||
priv->supplicant.mgr = NULL;
|
||||
}
|
||||
|
||||
if (priv->ssid) {
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
priv->ssid = NULL;
|
||||
}
|
||||
|
||||
|
||||
set_current_ap (self, NULL);
|
||||
remove_all_aps (self);
|
||||
}
|
||||
|
|
|
@ -617,6 +617,7 @@ free_get_settings_info (gpointer data)
|
|||
*(info->calls) = g_slist_remove (*(info->calls), info->call);
|
||||
if (g_slist_length (*(info->calls)) == 0) {
|
||||
g_slist_free (*(info->calls));
|
||||
g_slice_free (GSList, (gpointer) info->calls);
|
||||
g_signal_emit (info->manager,
|
||||
signals[CONNECTIONS_ADDED],
|
||||
0,
|
||||
|
@ -890,10 +891,10 @@ list_connections_cb (DBusGProxy *proxy,
|
|||
calls = g_slice_new0 (GSList *);
|
||||
|
||||
for (i = 0; i < ops->len; i++) {
|
||||
internal_new_connection_cb (proxy,
|
||||
g_ptr_array_index (ops, i),
|
||||
manager,
|
||||
calls);
|
||||
char *op = g_ptr_array_index (ops, i);
|
||||
|
||||
internal_new_connection_cb (proxy, op, manager, calls);
|
||||
g_free (op);
|
||||
}
|
||||
|
||||
g_ptr_array_free (ops, TRUE);
|
||||
|
@ -1059,10 +1060,11 @@ system_settings_get_unmanaged_devices_cb (DBusGProxy *proxy,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!G_VALUE_HOLDS (&value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH))
|
||||
return;
|
||||
if (G_VALUE_HOLDS (&value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH))
|
||||
handle_unmanaged_devices (manager, g_value_get_boxed (&value));
|
||||
|
||||
g_value_unset (&value);
|
||||
|
||||
handle_unmanaged_devices (manager, g_value_get_boxed (&value));
|
||||
g_object_unref (proxy);
|
||||
}
|
||||
|
||||
|
|
|
@ -436,12 +436,10 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
|
|||
g_string_append (str, elt->data); \
|
||||
} \
|
||||
} \
|
||||
value = g_strdup (str->str); \
|
||||
if (ucase) \
|
||||
value = g_ascii_strup (str->str, -1); \
|
||||
g_string_ascii_up (str); \
|
||||
success = nm_supplicant_config_add_option (self, name, str->str, -1, secret); \
|
||||
g_string_free (str, TRUE); \
|
||||
success = nm_supplicant_config_add_option (self, name, value, -1, secret); \
|
||||
g_free (value); \
|
||||
if (!success) { \
|
||||
nm_warning ("Error adding %s to supplicant config.", name); \
|
||||
return FALSE; \
|
||||
|
|
|
@ -534,7 +534,10 @@ scan_results_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
|||
|
||||
/* Fire off a "properties" call for each returned BSSID */
|
||||
for (i = 0; i < array->len; i++) {
|
||||
request_bssid_properties (info->interface, g_ptr_array_index (array, i));
|
||||
char *op = g_ptr_array_index (array, i);
|
||||
|
||||
request_bssid_properties (info->interface, op);
|
||||
g_free (op);
|
||||
}
|
||||
|
||||
g_ptr_array_free (array, TRUE);
|
||||
|
@ -654,6 +657,7 @@ iface_state_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
|||
NMSupplicantInfo *info = (NMSupplicantInfo *) user_data;
|
||||
|
||||
NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface)->con_state = wpas_state_string_to_enum (state_str);
|
||||
g_free (state_str);
|
||||
nm_supplicant_interface_set_state (info->interface,
|
||||
NM_SUPPLICANT_INTERFACE_STATE_READY);
|
||||
}
|
||||
|
@ -700,7 +704,7 @@ nm_supplicant_interface_add_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpoi
|
|||
} else {
|
||||
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (info->interface);
|
||||
|
||||
priv->object_path = g_strdup (path);
|
||||
priv->object_path = path;
|
||||
|
||||
priv->iface_proxy = dbus_g_proxy_new_for_name (nm_dbus_manager_get_connection (priv->dbus_mgr),
|
||||
WPAS_DBUS_SERVICE,
|
||||
|
@ -772,6 +776,8 @@ nm_supplicant_interface_add_to_supplicant (NMSupplicantInterface * self,
|
|||
DBUS_TYPE_G_MAP_OF_VARIANT, hash,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
g_value_unset (driver);
|
||||
g_free (driver);
|
||||
g_hash_table_destroy (hash);
|
||||
}
|
||||
|
||||
|
@ -1128,6 +1134,7 @@ add_network_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
|
|||
WPAS_DBUS_SERVICE,
|
||||
path,
|
||||
WPAS_DBUS_IFACE_NETWORK);
|
||||
g_free (path);
|
||||
|
||||
info = nm_supplicant_info_new (info->interface,
|
||||
priv->net_proxy,
|
||||
|
|
|
@ -392,6 +392,7 @@ svCloseFile(shvarFile *s)
|
|||
}
|
||||
g_free(s->fileName);
|
||||
g_list_free(s->freeList);
|
||||
g_list_foreach (s->lineList, (GFunc) g_free, NULL);
|
||||
g_list_free(s->lineList); /* implicitly frees s->current */
|
||||
g_free(s);
|
||||
return 0;
|
||||
|
|
|
@ -317,6 +317,7 @@ get_one_wep_key (shvarFile *ifcfg, guint8 idx, GError **err)
|
|||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY##idx, \
|
||||
key, \
|
||||
NULL); \
|
||||
g_free (key); \
|
||||
have_key = TRUE; \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -396,6 +396,7 @@ svCloseFile(shvarFile *s)
|
|||
}
|
||||
g_free(s->fileName);
|
||||
g_list_free(s->freeList);
|
||||
g_list_foreach (s->lineList, (GFunc) g_free, NULL);
|
||||
g_list_free(s->lineList); /* implicitly frees s->current */
|
||||
g_free(s);
|
||||
return 0;
|
||||
|
|
|
@ -201,6 +201,7 @@ read_one_setting_value (NMSetting *setting,
|
|||
|
||||
tmp_str = g_key_file_get_value (file, setting->name, key, NULL);
|
||||
uint_val = g_ascii_strtoull (tmp_str, NULL, 10);
|
||||
g_free (tmp_str);
|
||||
g_object_set (setting, key, uint_val, NULL);
|
||||
} else if (type == DBUS_TYPE_G_UCHAR_ARRAY) {
|
||||
gint *tmp;
|
||||
|
@ -223,6 +224,7 @@ read_one_setting_value (NMSetting *setting,
|
|||
|
||||
g_object_set (setting, key, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
g_free (tmp);
|
||||
} else if (type == dbus_g_type_get_collection ("GSList", G_TYPE_STRING)) {
|
||||
gchar **sa;
|
||||
gsize length;
|
||||
|
|
|
@ -83,22 +83,25 @@ static GObject *
|
|||
find_plugin (GSList *list, const char *pname)
|
||||
{
|
||||
GSList *iter;
|
||||
GObject *obj = NULL;
|
||||
|
||||
g_return_val_if_fail (pname != NULL, FALSE);
|
||||
|
||||
for (iter = list; iter; iter = g_slist_next (iter)) {
|
||||
for (iter = list; iter && !obj; iter = g_slist_next (iter)) {
|
||||
NMSystemConfigInterface *plugin = NM_SYSTEM_CONFIG_INTERFACE (iter->data);
|
||||
char *list_pname;
|
||||
char *list_pname = NULL;
|
||||
|
||||
g_object_get (G_OBJECT (plugin),
|
||||
NM_SYSTEM_CONFIG_INTERFACE_NAME,
|
||||
&list_pname,
|
||||
NULL);
|
||||
if (list_pname && !strcmp (pname, list_pname))
|
||||
return G_OBJECT (plugin);
|
||||
obj = G_OBJECT (plugin);
|
||||
|
||||
g_free (list_pname);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return obj;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -176,8 +179,12 @@ load_stuff (gpointer user_data)
|
|||
|
||||
/* Grab wired devices to make default DHCP connections for them if needed */
|
||||
devs = nm_system_config_hal_manager_get_devices_of_type (app->hal_mgr, DEVICE_TYPE_802_3_ETHERNET);
|
||||
for (iter = devs; iter; iter = g_slist_next (iter))
|
||||
for (iter = devs; iter; iter = g_slist_next (iter)) {
|
||||
device_added_cb (NULL, (const char *) iter->data, DEVICE_TYPE_802_3_ETHERNET, app);
|
||||
g_free (iter->data);
|
||||
}
|
||||
|
||||
g_slist_free (devs);
|
||||
|
||||
if (!start_dbus_service (app)) {
|
||||
g_main_loop_quit (app->loop);
|
||||
|
@ -273,6 +280,7 @@ have_connection_for_device (Application *app, GByteArray *mac)
|
|||
GSList *list, *iter;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
g_return_val_if_fail (app != NULL, FALSE);
|
||||
g_return_val_if_fail (mac != NULL, FALSE);
|
||||
|
@ -297,19 +305,28 @@ have_connection_for_device (Application *app, GByteArray *mac)
|
|||
s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
|
||||
|
||||
/* No wired setting; therefore the PPPoE connection applies to any device */
|
||||
if (!s_wired && !strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME))
|
||||
return TRUE;
|
||||
if (!s_wired && !strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (s_wired->mac_address) {
|
||||
/* A connection mac-locked to this device */
|
||||
if (!memcmp (s_wired->mac_address->data, mac->data, ETH_ALEN))
|
||||
return TRUE;
|
||||
if (!memcmp (s_wired->mac_address->data, mac->data, ETH_ALEN)) {
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* A connection that applies to any wired device */
|
||||
return TRUE;
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
g_slist_free (list);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -103,7 +103,7 @@ check_polkit_privileges (DBusGConnection *dbus_connection,
|
|||
GError **err)
|
||||
{
|
||||
DBusError dbus_error;
|
||||
const char *sender;
|
||||
char *sender;
|
||||
PolKitCaller *pk_caller;
|
||||
PolKitAction *pk_action;
|
||||
PolKitResult pk_result;
|
||||
|
@ -113,13 +113,17 @@ check_polkit_privileges (DBusGConnection *dbus_connection,
|
|||
pk_caller = polkit_caller_new_from_dbus_name (dbus_g_connection_get_connection (dbus_connection),
|
||||
sender,
|
||||
&dbus_error);
|
||||
if (!pk_caller) {
|
||||
g_free (sender);
|
||||
|
||||
if (dbus_error_is_set (&dbus_error)) {
|
||||
*err = g_error_new (NM_SYSCONFIG_SETTINGS_ERROR,
|
||||
NM_SYSCONFIG_SETTINGS_ERROR_NOT_PRIVILEGED,
|
||||
"Error getting information about caller: %s: %s",
|
||||
dbus_error.name, dbus_error.message);
|
||||
dbus_error_free (&dbus_error);
|
||||
polkit_caller_unref (pk_caller);
|
||||
|
||||
if (pk_caller)
|
||||
polkit_caller_unref (pk_caller);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -97,6 +97,9 @@ get_type_for_udi (NMSystemConfigHalManager *manager, const char *udi)
|
|||
else if (!strcmp (elt->data, "IS-707-A"))
|
||||
devtype = DEVICE_TYPE_CDMA;
|
||||
}
|
||||
|
||||
g_slist_foreach (csets, (GFunc) g_free, NULL);
|
||||
g_slist_free (csets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue