nautilus-sendto r391 - in trunk: . src/plugins/bluetooth



Author: hadess
Date: Thu Feb  5 12:24:03 2009
New Revision: 391
URL: http://svn.gnome.org/viewvc/nautilus-sendto?rev=391&view=rev

Log:
2009-02-05  Bastien Nocera  <hadess hadess net>

	* src/plugins/bluetooth/bluetooth.c (get_device_name_from_address),
	(add_last_used_device_to_list), (validate_destination):
	Fix possible memory leak when getting a device's name,
	Be more lax when checking whether the target device supports
	Obex Push, say that it does support Obex Push when:
	- it can't be found in the known devices list
	- the device has no UUIDs exported
	(Closes: #567485)



Modified:
   trunk/ChangeLog
   trunk/src/plugins/bluetooth/bluetooth.c

Modified: trunk/src/plugins/bluetooth/bluetooth.c
==============================================================================
--- trunk/src/plugins/bluetooth/bluetooth.c	(original)
+++ trunk/src/plugins/bluetooth/bluetooth.c	Thu Feb  5 12:24:03 2009
@@ -132,7 +132,7 @@
 }
 
 static char *
-get_device_name_from_address (char *bdaddr)
+get_device_name_from_address (const char *bdaddr)
 {
 	const char *device_path;
 	DBusGProxy *device;
@@ -141,9 +141,9 @@
 	if (dbus_g_proxy_call (object, "FindDevice", NULL,
 			       G_TYPE_STRING, bdaddr, G_TYPE_INVALID,
 			       DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID) == FALSE) {
-		return bdaddr;
+		return g_strdup (bdaddr);
 	}
-	    
+
 	device = dbus_g_proxy_new_for_name (conn, "org.bluez",
 					    device_path, "org.bluez.Device");
 
@@ -155,11 +155,13 @@
 		char *name;
 
 		value = g_hash_table_lookup (props, "Alias");
-		name = value ? g_value_get_string (value) : bdaddr;
+		name = value ? g_value_dup_string (value) : g_strdup (bdaddr);
+
+		g_hash_table_destroy (props);
 
 		return name;
 	} else {
-		return bdaddr;
+		return g_strdup (bdaddr);
 	}
 }
 
@@ -231,6 +233,7 @@
 	if (bdaddr != NULL && *bdaddr != '\0') {
 		name = get_device_name_from_address (bdaddr);
 		add_phone_to_list (store, name, bdaddr, NULL);
+		g_free (name);
 	}
 
 	g_free (bdaddr);
@@ -443,8 +446,7 @@
 			       G_TYPE_STRING, bdaddr, G_TYPE_INVALID,
 			       DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID) == FALSE) {
 		g_free (bdaddr);
-		*error = g_strdup (_("Programming error, could not find the device in the list"));
-		return FALSE;
+		return TRUE;
 	}
 
 	device = dbus_g_proxy_new_for_name (conn, "org.bluez",
@@ -486,6 +488,9 @@
 
 				g_free (uuid);
 			}
+		} else {
+			/* No array, can't really check now, can we */
+			found = TRUE;
 		}
 		g_hash_table_destroy (props);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]