From e3eebb408944850489bde0535949364c506dbc43 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 9 Oct 2009 09:38:37 +0200 Subject: [PATCH 4/4] don't remove NULL values from hash tables In device_remove(), device_file, object_path, or dev are sometimes NULL. Do not attempt to remove NULL from the hash tables, since this crashes. This is mainly a robustification patch, it does not really fix the underlying state bookkeeping. http://bugs.freedesktop.org/show_bug.cgi?id=24264 --- src/devkit-disks-daemon.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/devkit-disks-daemon.c b/src/devkit-disks-daemon.c index e3f5bc6..d9415c1 100644 --- a/src/devkit-disks-daemon.c +++ b/src/devkit-disks-daemon.c @@ -733,12 +733,20 @@ device_remove (DevkitDisksDaemon *daemon, GUdevDevice *d) g_warn_if_fail (g_hash_table_remove (daemon->priv->map_native_path_to_device, device->priv->native_path)); - g_warn_if_fail (g_hash_table_remove (daemon->priv->map_device_file_to_device, - device->priv->device_file)); - g_warn_if_fail (g_hash_table_remove (daemon->priv->map_object_path_to_device, - device->priv->object_path)); - g_warn_if_fail (g_hash_table_remove (daemon->priv->map_dev_t_to_device, - GINT_TO_POINTER (device->priv->dev))); + /* TODO: these three ought not to be NULL, but sometimes are. + * https://bugs.freedesktop.org/show_bug.cgi?id=24264 */ + if (device->priv->device_file) { + g_warn_if_fail (g_hash_table_remove (daemon->priv->map_device_file_to_device, + device->priv->device_file)); + } + if (device->priv->object_path) { + g_warn_if_fail (g_hash_table_remove (daemon->priv->map_object_path_to_device, + device->priv->object_path)); + } + if (device->priv->dev > 0) { + g_warn_if_fail (g_hash_table_remove (daemon->priv->map_dev_t_to_device, + GINT_TO_POINTER (device->priv->dev))); + } devkit_disks_device_removed (device); -- 1.6.3.3