diff options
Diffstat (limited to 'libbb/dirname.c')
-rw-r--r-- | libbb/dirname.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libbb/dirname.c b/libbb/dirname.c index 5f83994..87db1f2 100644 --- a/libbb/dirname.c +++ b/libbb/dirname.c @@ -22,7 +22,8 @@ #include <string.h> #include "libbb.h" -/* Return a string on the heap containing the directory component of PATH. */ +/* Return a string containing the path name of the parent + * directory of PATH. */ char *dirname(const char *path) { @@ -43,7 +44,8 @@ char *dirname(const char *path) s--; if (s < path) - return xstrdup ("."); - else - return xstrndup (path, s - path + 1); + return "."; + + s[1] = '\0'; + return path; } |