From b626a4677a0ba8e8e167cde24b9684cf920b9c56 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Mon, 24 Oct 2016 20:13:22 +0200 Subject: [PATCH] gunixmounts: Fix crash if path doesn't exist g_unix_mount_for segfaults for nonexistent paths. Return NULL if path doesn't exist. https://bugzilla.gnome.org/show_bug.cgi?id=772160 --- gio/gunixmounts.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c index 52be25a34..d08a4e282 100644 --- a/gio/gunixmounts.c +++ b/gio/gunixmounts.c @@ -1471,8 +1471,11 @@ g_unix_mount_for (const char *file_path, char *topdir; topdir = _g_local_file_find_topdir_for (file_path); - entry = g_unix_mount_at (topdir, time_read); - g_free (topdir); + if (topdir != NULL) + { + entry = g_unix_mount_at (topdir, time_read); + g_free (topdir); + } } return entry;