[glib] gunixmounts: Fix crash if path doesn't exist



commit b626a4677a0ba8e8e167cde24b9684cf920b9c56
Author: Ondrej Holy <oholy redhat com>
Date:   Mon Oct 24 20:13:22 2016 +0200

    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 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index 52be25a..d08a4e2 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;


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