diff options
| author | Christophe Fergeau <cfergeau@mandriva.com> | 2010-03-23 18:14:30 (GMT) |
|---|---|---|
| committer | Christophe Fergeau <cfergeau@mandriva.com> | 2010-03-23 18:34:36 (GMT) |
| commit | 5a4c30a2b1c939b48eb1a8f86ebe95b052d5ad03 (patch) | |
| tree | 41f864788f6fc2b1bc41f6f6ce255d7ae0439b05 | |
| parent | e6898ece4755a6d6d3a9f7bf72bb1b0e78cc0b2e (diff) | |
| download | rhythmbox-5a4c30a2b1c939b48eb1a8f86ebe95b052d5ad03.zip rhythmbox-5a4c30a2b1c939b48eb1a8f86ebe95b052d5ad03.tar.xz | |
[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
| -rw-r--r-- | 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; } |