From de2619271ee3ab42971fc770cae110f23e330c30 Mon Sep 17 00:00:00 2001 From: Andreas Henriksson Date: Tue, 15 Jul 2014 20:34:15 +0200 Subject: fileutil: avoid using PATH_MAX Use the dynamically allocated buffer returned by realpath instead of using PATH_MAX which is not defined on platforms like Hurd. --- src/gsystem-file-utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gsystem-file-utils.c b/src/gsystem-file-utils.c index 6a35ed7..c157d1d 100644 --- a/src/gsystem-file-utils.c +++ b/src/gsystem-file-utils.c @@ -1363,18 +1363,23 @@ GFile * gs_file_realpath (GFile *file) { gchar *path; - gchar path_real[PATH_MAX]; + char *path_real; + GFile *file_real; path = g_file_get_path (file); - if (realpath ((const char *) path, path_real) == NULL) + path_real = realpath((const char *) path, NULL); + if (path_real == NULL) { g_free (path); return NULL; } g_free (path); - return g_file_new_for_path (path_real); + file_real = g_file_new_for_path (path_real); + free (path_real); + + return file_real; } #ifdef GSYSTEM_CONFIG_XATTRS -- cgit v1.2.1