aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--noice.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/noice.c b/noice.c
index c3d3728..6b372fd 100644
--- a/noice.c
+++ b/noice.c
@@ -490,11 +490,16 @@ makepath(char *dir, char *name)
{
char *path;
- /* Handle root case */
- if (strcmp(dir, "/") == 0)
- asprintf(&path, "/%s", name);
- else
- asprintf(&path, "%s/%s", dir, name);
+ /* Handle absolute path */
+ if (name[0] == '/') {
+ path = xstrdup(name);
+ } else {
+ /* Handle root case */
+ if (strcmp(dir, "/") == 0)
+ asprintf(&path, "/%s", name);
+ else
+ asprintf(&path, "%s/%s", dir, name);
+ }
return path;
}