mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Just use xstrdup() in makepath()
This commit is contained in:
parent
89d0dc35ee
commit
3639f1bbb4
17
noice.c
17
noice.c
|
@ -452,24 +452,23 @@ dentfree(struct entry *dents, int n)
|
||||||
char *
|
char *
|
||||||
makepath(char *dir, char *name)
|
makepath(char *dir, char *name)
|
||||||
{
|
{
|
||||||
char *path;
|
char path[PATH_MAX];
|
||||||
|
|
||||||
/* Handle absolute path */
|
/* Handle absolute path */
|
||||||
if (name[0] == '/') {
|
if (name[0] == '/') {
|
||||||
path = xstrdup(name);
|
strlcpy(path, name, sizeof(path));
|
||||||
} else {
|
} else {
|
||||||
path = xmalloc(PATH_MAX);
|
|
||||||
/* Handle root case */
|
/* Handle root case */
|
||||||
if (strcmp(dir, "/") == 0) {
|
if (strcmp(dir, "/") == 0) {
|
||||||
strlcpy(path, "/", PATH_MAX);
|
strlcpy(path, "/", sizeof(path));
|
||||||
strlcat(path, name, PATH_MAX);
|
strlcat(path, name, sizeof(path));
|
||||||
} else {
|
} else {
|
||||||
strlcpy(path, dir, PATH_MAX);
|
strlcpy(path, dir, sizeof(path));
|
||||||
strlcat(path, "/", PATH_MAX);
|
strlcat(path, "/", sizeof(path));
|
||||||
strlcat(path, name, PATH_MAX);
|
strlcat(path, name, sizeof(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return xstrdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the position of the matching entry or 0 otherwise */
|
/* Return the position of the matching entry or 0 otherwise */
|
||||||
|
|
Loading…
Reference in a new issue