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 sep_count = 0;
|
||||
|
||||
u64 length = strlen(path);
|
||||
u64 full_length;
|
||||
u64 length;
|
||||
length = full_length = strlen(path);
|
||||
|
||||
if (path[length - 1] == path_sep) {
|
||||
--length;
|
||||
}
|
||||
@ -52,8 +55,14 @@ void dirup(char *dst, u64 levels, const char *path) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void join_root_and_leaf(const char *root, const char *leaf, char *dst) {
|
||||
u64 root_length = strlen(root);
|
||||
|
Loading…
Reference in New Issue
Block a user