diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-06-26 21:35:56 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-06-26 21:35:56 -0400 |
commit | 52d4444f8eec1a4e7e0861859c705c3a558b4e2a (patch) | |
tree | f7f206a988dbf47d77c1263a3c9353f9d83ce781 | |
parent | 21088aee2eb6bf12fd3b1db918ee4754989ff7da (diff) | |
download | musl-52d4444f8eec1a4e7e0861859c705c3a558b4e2a.tar.gz musl-52d4444f8eec1a4e7e0861859c705c3a558b4e2a.tar.bz2 musl-52d4444f8eec1a4e7e0861859c705c3a558b4e2a.tar.xz musl-52d4444f8eec1a4e7e0861859c705c3a558b4e2a.zip |
in sem_open, don't leak vm mapping if fstat fails
fstat should not fail under normal circumstances, so this fix is
mostly theoretical.
-rw-r--r-- | src/thread/sem_open.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c index ed2353c8..8a72d4c6 100644 --- 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; } |