From: Colin Clark Date: Sun, 15 Oct 2017 18:46:31 +0000 (+0100) Subject: Fix #527: source directory is not writable X-Git-Tag: v1.4~56 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=74096520939903d9a070378d5d40c32a5d44b6c2 Fix #527: source directory is not writable https://github.com/BestImageViewer/geeqie/issues/527 The case of a file being in the root ( / ) folder not taken into account --- diff --git a/src/ui_fileops.c b/src/ui_fileops.c index 99a82166..ad015b26 100644 --- a/src/ui_fileops.c +++ b/src/ui_fileops.c @@ -744,7 +744,9 @@ gchar *remove_level_from_path(const gchar *path) if (!path) return NULL; base = strrchr(path, G_DIR_SEPARATOR); - if (base) return g_strndup(path, strlen(path)-strlen(base)); + /* Take account of a file being in the root ( / ) folder - ensure the returned value + * is at least one character long */ + if (base) return g_strndup(path, (strlen(path)-strlen(base)) == 0 ? 1 : (strlen(path)-strlen(base))); return NULL; }