mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 12:37:35 +00:00
Merge pull request #1212 from brauner/2016-09-26/fix_lxc_deslashify
utils: lxc_deslashify() free memory
This commit is contained in:
commit
92281f0275
@ -718,6 +718,7 @@ char **lxc_normalize_path(const char *path)
|
|||||||
|
|
||||||
bool lxc_deslashify(char **path)
|
bool lxc_deslashify(char **path)
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
char *p;
|
char *p;
|
||||||
char **parts = NULL;
|
char **parts = NULL;
|
||||||
size_t n, len;
|
size_t n, len;
|
||||||
@ -729,28 +730,33 @@ bool lxc_deslashify(char **path)
|
|||||||
/* We'll end up here if path == "///" or path == "". */
|
/* We'll end up here if path == "///" or path == "". */
|
||||||
if (!*parts) {
|
if (!*parts) {
|
||||||
len = strlen(*path);
|
len = strlen(*path);
|
||||||
if (!len)
|
if (!len) {
|
||||||
return true;
|
ret = true;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
n = strcspn(*path, "/");
|
n = strcspn(*path, "/");
|
||||||
if (n == len) {
|
if (n == len) {
|
||||||
p = strdup("/");
|
p = strdup("/");
|
||||||
if (!p)
|
if (!p)
|
||||||
return false;
|
goto out;
|
||||||
free(*path);
|
free(*path);
|
||||||
*path = p;
|
*path = p;
|
||||||
return true;
|
ret = true;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = lxc_string_join("/", (const char **)parts, **path == '/');
|
p = lxc_string_join("/", (const char **)parts, **path == '/');
|
||||||
lxc_free_array((void **)parts, free);
|
|
||||||
if (!p)
|
if (!p)
|
||||||
return false;
|
goto out;
|
||||||
|
|
||||||
free(*path);
|
free(*path);
|
||||||
*path = p;
|
*path = p;
|
||||||
|
ret = true;
|
||||||
|
|
||||||
return true;
|
out:
|
||||||
|
lxc_free_array((void **)parts, free);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *lxc_append_paths(const char *first, const char *second)
|
char *lxc_append_paths(const char *first, const char *second)
|
||||||
|
Loading…
Reference in New Issue
Block a user