chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shared: path-util - memory leak
[elogind.git]
/
src
/
shared
/
path-util.c
diff --git
a/src/shared/path-util.c
b/src/shared/path-util.c
index be03695cf866e06fcc3c33d59e524a233e81f33b..3256deeec1e3535f25da63c48ba3a978fb49674d 100644
(file)
--- a/
src/shared/path-util.c
+++ b/
src/shared/path-util.c
@@
-129,7
+129,7
@@
char *path_make_absolute_cwd(const char *p) {
if (!cwd)
return NULL;
if (!cwd)
return NULL;
- return
path_make_absolute(p, cwd
);
+ return
strjoin(cwd, "/", p, NULL
);
}
int path_make_relative(const char *from_dir, const char *to_path, char **_r) {
}
int path_make_relative(const char *from_dir, const char *to_path, char **_r) {
@@
-306,6
+306,7
@@
char **path_strv_resolve(char **l, const char *prefix) {
} else {
/* canonicalized path goes outside of
* prefix, keep the original path instead */
} else {
/* canonicalized path goes outside of
* prefix, keep the original path instead */
+ free(u);
u = orig;
orig = NULL;
}
u = orig;
orig = NULL;
}
@@
-439,14
+440,14
@@
char* path_join(const char *root, const char *path, const char *rest) {
assert(path);
if (!isempty(root))
assert(path);
if (!isempty(root))
- return strjoin(root, "/",
+ return strjoin(root,
endswith(root, "/") ? "" :
"/",
path[0] == '/' ? path+1 : path,
path[0] == '/' ? path+1 : path,
- rest ?
"/"
: NULL,
+ rest ?
(endswith(path, "/") ? "" : "/")
: NULL,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
else
return strjoin(path,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
else
return strjoin(path,
- rest ?
"/"
: NULL,
+ rest ?
(endswith(path, "/") ? "" : "/")
: NULL,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
}
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
}