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:
21088ae
)
in sem_open, don't leak vm mapping if fstat fails
author
Rich Felker
<dalias@aerifal.cx>
Thu, 27 Jun 2013 01:35:56 +0000
(21:35 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 27 Jun 2013 01:35:56 +0000
(21:35 -0400)
fstat should not fail under normal circumstances, so this fix is
mostly theoretical.
src/thread/sem_open.c
patch
|
blob
|
history
diff --git
a/src/thread/sem_open.c
b/src/thread/sem_open.c
index ed2353c8ba3afd9ef12b3211c322dfa92ddd805a..8a72d4c62a317314e077716c7569306a349a90c8 100644
(file)
--- a/
src/thread/sem_open.c
+++ b/
src/thread/sem_open.c
@@
-82,8
+82,8
@@
sem_t *sem_open(const char *name, int flags, ...)
if (flags != (O_CREAT|O_EXCL)) {
fd = open(name, FLAGS);
if (fd >= 0) {
- if (
(map = mmap(0, sizeof(sem_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED
||
-
fstat(fd, &st) < 0
) {
+ if (
fstat(fd, &st) < 0
||
+
(map = mmap(0, sizeof(sem_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED
) {
close(fd);
goto fail;
}