NetworkManager r3721 - in trunk: . libnm-util src src/backends src/supplicant-manager system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/plugins/keyfile system-settings/src
- From: tambeti svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3721 - in trunk: . libnm-util src src/backends src/supplicant-manager system-settings/plugins/ifcfg-fedora system-settings/plugins/ifcfg-suse system-settings/plugins/keyfile system-settings/src
- Date: Thu, 5 Jun 2008 13:16:03 +0000 (UTC)
Author: tambeti
Date: Thu Jun 5 13:16:02 2008
New Revision: 3721
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3721&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/libnm-util/nm-setting.c
trunk/src/backends/shvar.c
trunk/src/nm-device-802-11-wireless.c
trunk/src/nm-manager.c
trunk/src/supplicant-manager/nm-supplicant-config.c
trunk/src/supplicant-manager/nm-supplicant-interface.c
trunk/system-settings/plugins/ifcfg-fedora/shvar.c
trunk/system-settings/plugins/ifcfg-suse/parser.c
trunk/system-settings/plugins/ifcfg-suse/shvar.c
trunk/system-settings/plugins/keyfile/reader.c
trunk/system-settings/src/main.c
trunk/system-settings/src/nm-polkit-helpers.c
trunk/system-settings/src/nm-system-config-hal-manager.c
Modified: trunk/libnm-util/nm-setting.c
==============================================================================
--- trunk/libnm-util/nm-setting.c (original)
+++ trunk/libnm-util/nm-setting.c Thu Jun 5 13:16:02 2008
@@ -107,6 +107,7 @@
{
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 @@
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);
Modified: trunk/src/backends/shvar.c
==============================================================================
--- trunk/src/backends/shvar.c (original)
+++ trunk/src/backends/shvar.c Thu Jun 5 13:16:02 2008
@@ -392,6 +392,7 @@
}
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;
Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c (original)
+++ trunk/src/nm-device-802-11-wireless.c Thu Jun 5 13:16:02 2008
@@ -828,6 +828,12 @@
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);
}
Modified: trunk/src/nm-manager.c
==============================================================================
--- trunk/src/nm-manager.c (original)
+++ trunk/src/nm-manager.c Thu Jun 5 13:16:02 2008
@@ -617,6 +617,7 @@
*(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 @@
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 @@
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);
}
Modified: trunk/src/supplicant-manager/nm-supplicant-config.c
==============================================================================
--- trunk/src/supplicant-manager/nm-supplicant-config.c (original)
+++ trunk/src/supplicant-manager/nm-supplicant-config.c Thu Jun 5 13:16:02 2008
@@ -436,12 +436,10 @@
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; \
Modified: trunk/src/supplicant-manager/nm-supplicant-interface.c
==============================================================================
--- trunk/src/supplicant-manager/nm-supplicant-interface.c (original)
+++ trunk/src/supplicant-manager/nm-supplicant-interface.c Thu Jun 5 13:16:02 2008
@@ -534,7 +534,10 @@
/* 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 @@
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 @@
} 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 @@
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 @@
WPAS_DBUS_SERVICE,
path,
WPAS_DBUS_IFACE_NETWORK);
+ g_free (path);
info = nm_supplicant_info_new (info->interface,
priv->net_proxy,
Modified: trunk/system-settings/plugins/ifcfg-fedora/shvar.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-fedora/shvar.c (original)
+++ trunk/system-settings/plugins/ifcfg-fedora/shvar.c Thu Jun 5 13:16:02 2008
@@ -392,6 +392,7 @@
}
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;
Modified: trunk/system-settings/plugins/ifcfg-suse/parser.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-suse/parser.c (original)
+++ trunk/system-settings/plugins/ifcfg-suse/parser.c Thu Jun 5 13:16:02 2008
@@ -317,6 +317,7 @@
NM_SETTING_WIRELESS_SECURITY_WEP_KEY##idx, \
key, \
NULL); \
+ g_free (key); \
have_key = TRUE; \
} \
}
Modified: trunk/system-settings/plugins/ifcfg-suse/shvar.c
==============================================================================
--- trunk/system-settings/plugins/ifcfg-suse/shvar.c (original)
+++ trunk/system-settings/plugins/ifcfg-suse/shvar.c Thu Jun 5 13:16:02 2008
@@ -396,6 +396,7 @@
}
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;
Modified: trunk/system-settings/plugins/keyfile/reader.c
==============================================================================
--- trunk/system-settings/plugins/keyfile/reader.c (original)
+++ trunk/system-settings/plugins/keyfile/reader.c Thu Jun 5 13:16:02 2008
@@ -201,6 +201,7 @@
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 @@
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;
Modified: trunk/system-settings/src/main.c
==============================================================================
--- trunk/system-settings/src/main.c (original)
+++ trunk/system-settings/src/main.c Thu Jun 5 13:16:02 2008
@@ -83,22 +83,25 @@
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 @@
/* 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 @@
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 @@
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
Modified: trunk/system-settings/src/nm-polkit-helpers.c
==============================================================================
--- trunk/system-settings/src/nm-polkit-helpers.c (original)
+++ trunk/system-settings/src/nm-polkit-helpers.c Thu Jun 5 13:16:02 2008
@@ -103,7 +103,7 @@
GError **err)
{
DBusError dbus_error;
- const char *sender;
+ char *sender;
PolKitCaller *pk_caller;
PolKitAction *pk_action;
PolKitResult pk_result;
@@ -113,13 +113,17 @@
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;
}
Modified: trunk/system-settings/src/nm-system-config-hal-manager.c
==============================================================================
--- trunk/system-settings/src/nm-system-config-hal-manager.c (original)
+++ trunk/system-settings/src/nm-system-config-hal-manager.c Thu Jun 5 13:16:02 2008
@@ -97,6 +97,9 @@
else if (!strcmp (elt->data, "IS-707-A"))
devtype = DEVICE_TYPE_CDMA;
}
+
+ g_slist_foreach (csets, (GFunc) g_free, NULL);
+ g_slist_free (csets);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]