aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 049219b..a99c613 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -227,13 +227,9 @@ static char *make_path(const char *dir, const char *name)
{
char *s;
- s = malloc(strlen(dir) + strlen(name) + 2);
- if (!s)
- return NULL;
- strcpy(s, dir);
- if (dir[strlen(dir) - 1] != '/')
- strcat(s, "/");
- strcat(s, name);
+ xasprintf(&s, "%s%s%s",
+ dir, dir[strlen(dir) - 1] == '/' ? "" : "/", name);
+
return s;
}