diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-06-26 21:41:51 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-06-26 21:41:51 -0400 |
commit | 7c20a11801fd56cbadac5a6e88ddddf8656ac1bc (patch) | |
tree | 856af354be7ad0c88170eb43b5e59c7ad5a8f6a7 /src/thread | |
parent | a033cd22aa0ecd9f494b74669d358e7e1c7e1335 (diff) | |
download | musl-7c20a11801fd56cbadac5a6e88ddddf8656ac1bc.tar.gz musl-7c20a11801fd56cbadac5a6e88ddddf8656ac1bc.tar.bz2 musl-7c20a11801fd56cbadac5a6e88ddddf8656ac1bc.tar.xz musl-7c20a11801fd56cbadac5a6e88ddddf8656ac1bc.zip |
fix temp file leak in sem_open on successful creation of new semaphore
Diffstat (limited to 'src/thread')
-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 66f12ee4..9a95d257 100644 --- a/src/thread/sem_open.c +++ b/src/thread/sem_open.c @@ -123,9 +123,9 @@ sem_t *sem_open(const char *name, int flags, ...) goto fail; } close(fd); - if (link(tmp, name) == 0) break; - e = errno; + e = link(tmp, name) ? errno : 0; unlink(tmp); + if (!e) break; /* Failure is only fatal when doing an exclusive open; * otherwise, next iteration will try to open the * existing file. */ |