Fix bug with the dirup function
This commit is contained in:
parent
f1b29d1c3f
commit
75acf7da5d
@ -32,7 +32,10 @@ void dirup(char *dst, u64 levels, const char *path) {
|
|||||||
u64 end_index = 0;
|
u64 end_index = 0;
|
||||||
u64 sep_count = 0;
|
u64 sep_count = 0;
|
||||||
|
|
||||||
u64 length = strlen(path);
|
u64 full_length;
|
||||||
|
u64 length;
|
||||||
|
length = full_length = strlen(path);
|
||||||
|
|
||||||
if (path[length - 1] == path_sep) {
|
if (path[length - 1] == path_sep) {
|
||||||
--length;
|
--length;
|
||||||
}
|
}
|
||||||
@ -52,7 +55,13 @@ void dirup(char *dst, u64 levels, const char *path) {
|
|||||||
end_index = 0;
|
end_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dst == path) {
|
||||||
|
memset(&dst[end_index], 0, full_length - end_index);
|
||||||
|
} else {
|
||||||
|
u64 dst_length = strlen(dst);
|
||||||
|
memset(dst, 0, dst_length);
|
||||||
strncpy(dst, path, end_index);
|
strncpy(dst, path, end_index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void join_root_and_leaf(const char *root, const char *leaf, char *dst) {
|
void join_root_and_leaf(const char *root, const char *leaf, char *dst) {
|
||||||
|
Loading…
Reference in New Issue
Block a user