diff options
author | Alberto Ruiz <aruiz@gnome.org> | 2013-07-17 23:53:10 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@gnome.org> | 2013-07-18 00:06:05 +0200 |
commit | ddcaa639e4fa1103cc43318882b447b98890e370 (patch) | |
tree | 251b2a12bfd0f299fce57056d8e37b2909c98ec8 | |
parent | 4a41cb7911ac97eeac297a3177375b8198a433d2 (diff) | |
download | libgsystem-ddcaa639e4fa1103cc43318882b447b98890e370.tar.gz |
fileutils: Handles return value of realpath in case of errors
Signed-off-by: Alberto Ruiz <aruiz@gnome.org>
-rw-r--r-- | gsystem-file-utils.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c index 69a2caf..cc7fa98 100644 --- a/gsystem-file-utils.c +++ b/gsystem-file-utils.c @@ -1025,7 +1025,7 @@ gs_file_get_relpath (GFile *one, * followed. That is, it's a #GFile whose path is the result * of calling realpath() on @file. * - * Returns: (transfer full): A new #GFile + * Returns: (allow-none) (transfer full): A new #GFile or %NULL if @file is invalid */ GFile * gs_file_realpath (GFile *file) @@ -1034,7 +1034,13 @@ gs_file_realpath (GFile *file) gchar path_real[PATH_MAX]; path = g_file_get_path (file); - realpath ((const char *) path, path_real); + + if (realpath ((const char *) path, path_real) == NULL) + { + g_free (path); + return NULL; + } + g_free (path); return g_file_new_for_path (path_real); } |