diff options
-rw-r--r-- | utility.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1731,14 +1731,16 @@ char *get_last_path_component(char *path) | |||
1731 | char *s=path+strlen(path)-1; | 1731 | char *s=path+strlen(path)-1; |
1732 | 1732 | ||
1733 | /* strip trailing slashes */ | 1733 | /* strip trailing slashes */ |
1734 | while (s && *s == '/') { | 1734 | while (s != path && *s == '/') { |
1735 | *s-- = '\0'; | 1735 | *s-- = '\0'; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | /* find last component */ | 1738 | /* find last component */ |
1739 | s = strrchr(path, '/'); | 1739 | s = strrchr(path, '/'); |
1740 | if (s==NULL) return path; | 1740 | if (s == NULL || s[1] == '\0') |
1741 | else return s+1; | 1741 | return path; |
1742 | else | ||
1743 | return s+1; | ||
1742 | } | 1744 | } |
1743 | #endif | 1745 | #endif |
1744 | 1746 | ||