projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5a2e74e
)
fix memory leak on failure in realpath
author
Rich Felker
<dalias@aerifal.cx>
Sat, 18 Jun 2011 11:41:14 +0000
(07:41 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Sat, 18 Jun 2011 11:41:14 +0000
(07:41 -0400)
src/misc/realpath.c
patch
|
blob
|
history
diff --git
a/src/misc/realpath.c
b/src/misc/realpath.c
index 8dcf5ec9fc8792e0299b656fee5a11700ad2348a..ef156fcf8aaf1cb808e4a3760a46df3855676ce8 100644
(file)
--- a/
src/misc/realpath.c
+++ b/
src/misc/realpath.c
@@
-19,16
+19,16
@@
char *realpath(const char *filename, char *resolved)
return 0;
}
+ fd = open(filename, O_RDONLY|O_NONBLOCK);
+ if (fd < 0) return 0;
+ snprintf(buf, sizeof buf, "/proc/self/fd/%d", fd);
+
if (!resolved) {
alloc = 1;
resolved = malloc(PATH_MAX);
if (!resolved) return 0;
}
- fd = open(filename, O_RDONLY|O_NONBLOCK);
- if (fd < 0) return 0;
- snprintf(buf, sizeof buf, "/proc/self/fd/%d", fd);
-
r = readlink(buf, resolved, PATH_MAX-1);
if (r < 0) goto err;
resolved[r] = 0;