trivial: let g_free and g_strdup handle NULL (bgo #644763)
This commit is contained in:

committed by
Dan Williams

parent
925f21f7c2
commit
b224ab8e56
@@ -508,7 +508,6 @@ finalize (GObject *object)
|
|||||||
if (priv->ssid)
|
if (priv->ssid)
|
||||||
g_byte_array_free (priv->ssid, TRUE);
|
g_byte_array_free (priv->ssid, TRUE);
|
||||||
|
|
||||||
if (priv->bssid)
|
|
||||||
g_free (priv->bssid);
|
g_free (priv->bssid);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_access_point_parent_class)->finalize (object);
|
||||||
|
@@ -322,10 +322,7 @@ finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);
|
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (object);
|
||||||
|
|
||||||
if (priv->hw_address)
|
|
||||||
g_free (priv->hw_address);
|
g_free (priv->hw_address);
|
||||||
|
|
||||||
if (priv->perm_hw_address)
|
|
||||||
g_free (priv->perm_hw_address);
|
g_free (priv->perm_hw_address);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_device_ethernet_parent_class)->finalize (object);
|
||||||
|
@@ -763,10 +763,7 @@ finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
|
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
|
||||||
|
|
||||||
if (priv->hw_address)
|
|
||||||
g_free (priv->hw_address);
|
g_free (priv->hw_address);
|
||||||
|
|
||||||
if (priv->perm_hw_address)
|
|
||||||
g_free (priv->perm_hw_address);
|
g_free (priv->perm_hw_address);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
|
||||||
|
@@ -186,9 +186,7 @@ finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
|
NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (object);
|
||||||
|
|
||||||
if (priv->banner)
|
|
||||||
g_free (priv->banner);
|
g_free (priv->banner);
|
||||||
|
|
||||||
g_object_unref (priv->proxy);
|
g_object_unref (priv->proxy);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_vpn_connection_parent_class)->finalize (object);
|
||||||
|
@@ -1024,10 +1024,8 @@ nm_connection_set_path (NMConnection *connection, const char *path)
|
|||||||
|
|
||||||
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
priv = NM_CONNECTION_GET_PRIVATE (connection);
|
||||||
|
|
||||||
if (priv->path) {
|
|
||||||
g_free (priv->path);
|
g_free (priv->path);
|
||||||
priv->path = NULL;
|
priv->path = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (path)
|
if (path)
|
||||||
priv->path = g_strdup (path);
|
priv->path = g_strdup (path);
|
||||||
|
@@ -502,8 +502,6 @@ finalize (GObject *object)
|
|||||||
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object);
|
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object);
|
||||||
|
|
||||||
g_free (priv->method);
|
g_free (priv->method);
|
||||||
|
|
||||||
if (priv->dns)
|
|
||||||
g_slist_free (priv->dns);
|
g_slist_free (priv->dns);
|
||||||
|
|
||||||
nm_utils_slist_free (priv->dns_search, g_free);
|
nm_utils_slist_free (priv->dns_search, g_free);
|
||||||
|
@@ -195,7 +195,7 @@ property_changed (DBusGProxy *proxy,
|
|||||||
|| (priv->name && !str)
|
|| (priv->name && !str)
|
||||||
|| (priv->name && str && strcmp (priv->name, str))) {
|
|| (priv->name && str && strcmp (priv->name, str))) {
|
||||||
g_free (priv->name);
|
g_free (priv->name);
|
||||||
priv->name = str ? g_strdup (str) : NULL;
|
priv->name = g_strdup (str);
|
||||||
g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_NAME);
|
g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_NAME);
|
||||||
}
|
}
|
||||||
} else if (!strcmp (property, "RSSI")) {
|
} else if (!strcmp (property, "RSSI")) {
|
||||||
|
@@ -216,7 +216,6 @@ nm_act_request_set_specific_object (NMActRequest *req,
|
|||||||
|
|
||||||
priv = NM_ACT_REQUEST_GET_PRIVATE (req);
|
priv = NM_ACT_REQUEST_GET_PRIVATE (req);
|
||||||
|
|
||||||
if (priv->specific_object)
|
|
||||||
g_free (priv->specific_object);
|
g_free (priv->specific_object);
|
||||||
priv->specific_object = g_strdup (specific_object);
|
priv->specific_object = g_strdup (specific_object);
|
||||||
}
|
}
|
||||||
|
@@ -192,7 +192,6 @@ set_property (GObject *object, guint prop_id,
|
|||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PARENT_IFACE:
|
case PROP_PARENT_IFACE:
|
||||||
if (priv->parent_iface)
|
|
||||||
g_free (priv->parent_iface);
|
g_free (priv->parent_iface);
|
||||||
priv->parent_iface = g_value_dup_string (value);
|
priv->parent_iface = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
|
@@ -501,7 +501,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
|
|||||||
svCloseFile (network);
|
svCloseFile (network);
|
||||||
|
|
||||||
g_free (priv->hostname);
|
g_free (priv->hostname);
|
||||||
priv->hostname = hostname ? g_strdup (hostname) : NULL;
|
priv->hostname = g_strdup (hostname);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -90,8 +90,8 @@ svOpenFile(const char *name, gboolean create)
|
|||||||
|
|
||||||
bail:
|
bail:
|
||||||
if (s->fd != -1) close(s->fd);
|
if (s->fd != -1) close(s->fd);
|
||||||
if (s->arena) g_free (s->arena);
|
g_free (s->arena);
|
||||||
if (s->fileName) g_free (s->fileName);
|
g_free (s->fileName);
|
||||||
g_free (s);
|
g_free (s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -195,7 +195,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (priv->hostname);
|
g_free (priv->hostname);
|
||||||
priv->hostname = hostname ? g_strdup (hostname) : NULL;
|
priv->hostname = g_strdup (hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -470,7 +470,6 @@ eap_ttls_reader (const char *eap_method,
|
|||||||
done:
|
done:
|
||||||
if (list)
|
if (list)
|
||||||
g_strfreev (list);
|
g_strfreev (list);
|
||||||
if (inner_auth)
|
|
||||||
g_free (inner_auth);
|
g_free (inner_auth);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@@ -158,7 +158,6 @@ finalize (GObject * object)
|
|||||||
NM_IFNET_CONNECTION_GET_PRIVATE (object);
|
NM_IFNET_CONNECTION_GET_PRIVATE (object);
|
||||||
g_return_if_fail (priv);
|
g_return_if_fail (priv);
|
||||||
|
|
||||||
if (priv->conn_name)
|
|
||||||
g_free (priv->conn_name);
|
g_free (priv->conn_name);
|
||||||
G_OBJECT_CLASS (nm_ifnet_connection_parent_class)->finalize (object);
|
G_OBJECT_CLASS (nm_ifnet_connection_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,6 @@ update_system_hostname (gpointer config)
|
|||||||
|
|
||||||
PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Updating hostname");
|
PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Updating hostname");
|
||||||
|
|
||||||
if (priv->hostname)
|
|
||||||
g_free (priv->hostname);
|
g_free (priv->hostname);
|
||||||
priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE);
|
priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE);
|
||||||
|
|
||||||
@@ -110,7 +109,6 @@ write_system_hostname (NMSystemConfigInterface * config,
|
|||||||
PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Write system hostname: %s",
|
PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Write system hostname: %s",
|
||||||
newhostname);
|
newhostname);
|
||||||
if (write_hostname (newhostname, IFNET_SYSTEM_HOSTNAME_FILE)) {
|
if (write_hostname (newhostname, IFNET_SYSTEM_HOSTNAME_FILE)) {
|
||||||
if (priv->hostname)
|
|
||||||
g_free (priv->hostname);
|
g_free (priv->hostname);
|
||||||
priv->hostname = g_strdup (newhostname);
|
priv->hostname = g_strdup (newhostname);
|
||||||
g_object_notify (G_OBJECT (config),
|
g_object_notify (G_OBJECT (config),
|
||||||
@@ -512,7 +510,6 @@ dispose (GObject * object)
|
|||||||
g_hash_table_destroy (priv->config_connections);
|
g_hash_table_destroy (priv->config_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->hostname)
|
|
||||||
g_free (priv->hostname);
|
g_free (priv->hostname);
|
||||||
ifnet_destroy ();
|
ifnet_destroy ();
|
||||||
wpa_parser_destroy ();
|
wpa_parser_destroy ();
|
||||||
|
@@ -600,9 +600,7 @@ update_system_hostname(NMInotifyHelper *inotify_helper,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->hostname)
|
|
||||||
g_free(priv->hostname);
|
g_free(priv->hostname);
|
||||||
|
|
||||||
priv->hostname = g_strstrip(hostname_file);
|
priv->hostname = g_strstrip(hostname_file);
|
||||||
|
|
||||||
/* We shouldn't return a zero-length hostname, but NULL */
|
/* We shouldn't return a zero-length hostname, but NULL */
|
||||||
|
@@ -493,7 +493,7 @@ plugin_set_hostname (SCPluginKeyfile *plugin, const char *hostname)
|
|||||||
g_free (data);
|
g_free (data);
|
||||||
|
|
||||||
g_free (priv->hostname);
|
g_free (priv->hostname);
|
||||||
priv->hostname = hostname ? g_strdup (hostname) : NULL;
|
priv->hostname = g_strdup (hostname);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -474,7 +474,6 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||||||
|
|
||||||
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP4_CONFIG_BANNER);
|
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP4_CONFIG_BANNER);
|
||||||
if (val) {
|
if (val) {
|
||||||
if (priv->banner)
|
|
||||||
g_free (priv->banner);
|
g_free (priv->banner);
|
||||||
priv->banner = g_strdup (g_value_get_string (val));
|
priv->banner = g_strdup (g_value_get_string (val));
|
||||||
}
|
}
|
||||||
@@ -954,15 +953,11 @@ vpn_cleanup (NMVPNConnection *connection)
|
|||||||
priv->gw_route = NULL;
|
priv->gw_route = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->banner) {
|
|
||||||
g_free (priv->banner);
|
g_free (priv->banner);
|
||||||
priv->banner = NULL;
|
priv->banner = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->ip_iface) {
|
|
||||||
g_free (priv->ip_iface);
|
g_free (priv->ip_iface);
|
||||||
priv->ip_iface = NULL;
|
priv->ip_iface = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear out connection secrets to ensure that the settings service
|
/* Clear out connection secrets to ensure that the settings service
|
||||||
* gets asked for them next time the connection is activated.
|
* gets asked for them next time the connection is activated.
|
||||||
|
Reference in New Issue
Block a user