[rhythmbox] [mtp] ignore mounts not associated with a device node
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] [mtp] ignore mounts not associated with a device node
- Date: Tue, 23 Mar 2010 20:31:31 +0000 (UTC)
commit 5a4c30a2b1c939b48eb1a8f86ebe95b052d5ad03
Author: Christophe Fergeau <cfergeau mandriva com>
Date: Tue Mar 23 19:14:30 2010 +0100
[mtp] ignore mounts not associated with a device node
The mtp plugin tries to find the GMount associated with a given unix device
node, but it doesn't ignore GMount which do not have an associated device
node which can happen with an iPhone for example. Not ignoring these causes
the crash described in bug #613715. This also fixes a small reference leak
in the "mounts" list
plugins/mtpdevice/rb-mtp-source.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/plugins/mtpdevice/rb-mtp-source.c b/plugins/mtpdevice/rb-mtp-source.c
index 7d67f55..82030a5 100644
--- a/plugins/mtpdevice/rb-mtp-source.c
+++ b/plugins/mtpdevice/rb-mtp-source.c
@@ -1435,6 +1435,9 @@ find_mount_for_device (GUdevDevice *device)
GList *i;
device_file = g_udev_device_get_device_file (device);
+ if (device_file == NULL) {
+ return NULL;
+ }
volmon = g_volume_monitor_get ();
mounts = g_volume_monitor_get_mounts (volmon);
@@ -1443,23 +1446,27 @@ find_mount_for_device (GUdevDevice *device)
for (i = mounts; i != NULL; i = i->next) {
GVolume *v;
- mount = G_MOUNT (i->data);
- v = g_mount_get_volume (mount);
+ v = g_mount_get_volume (G_MOUNT (i->data));
if (v != NULL) {
char *devname = NULL;
gboolean match;
devname = g_volume_get_identifier (v, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ g_object_unref (v);
+ if (devname == NULL)
+ continue;
+
match = g_str_equal (devname, device_file);
g_free (devname);
- g_object_unref (v);
- if (match)
+ if (match) {
+ mount = G_MOUNT (i->data);
+ g_object_ref (G_OBJECT (mount));
break;
+ }
}
- g_object_unref (mount);
- mount = NULL;
}
+ g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
g_list_free (mounts);
return mount;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]