changeset 2634:8cdd84a6a8e9

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
author Colin Clark <colin.clark@cclark.uk>
date Sun, 15 Oct 2017 19:46:31 +0100
parents 13fb4ad982fc
children e2b9dff749d3
files src/ui_fileops.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ui_fileops.c	Sun Oct 15 11:50:37 2017 +0100
+++ b/src/ui_fileops.c	Sun Oct 15 19:46:31 2017 +0100
@@ -744,7 +744,9 @@
 	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;
 }