summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 02328388d2a..e2c2f10b891 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -709,6 +709,7 @@ char *
libgf_trim_to_prev_dir (char * path)
{
char *idx = NULL;
+ int len = 0;
if (!path)
return NULL;
@@ -716,9 +717,14 @@ libgf_trim_to_prev_dir (char * path)
/* Check if we're already at root, if yes
* then there is no prev dir.
*/
- if (strlen (path) == 1)
+ len = strlen (path);
+ if (len == 1)
return path;
+ if (path[len - 1] == '/') {
+ path[len - 1] = '\0';
+ }
+
idx = libgf_rrindex (path, '/', 1);
/* Move to the char after the / */
++idx;